Skip to content

Commit 1e31b71

Browse files
Added e2e test for analytics sdk
1 parent a986bef commit 1e31b71

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

e2e/e2e.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2019 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
13+
const sdk = require('../src/index')
14+
const util = require("util")
15+
16+
var sdkClient = {}
17+
const company = process.env['ANALYTICS_COMPANY']
18+
const apiKey = process.env['ANALYTICS_APIKEY']
19+
const token = process.env['ANALYTICS_TOKEN']
20+
const rsid = process.env['ANALYTICS_RSID']
21+
22+
test('sdk init test', async () => {
23+
24+
sdkClient = await sdk.init(company, apiKey, token)
25+
26+
expect(sdkClient.companyId).toBe(company)
27+
expect(sdkClient.apiKey).toBe(apiKey)
28+
expect(sdkClient.token).toBe(token)
29+
30+
});
31+
32+
test('test getCollections', async () => {
33+
//check success response
34+
var res = await sdkClient.getCollections({limit:5, page:0})
35+
expect(res.totalElements).toEqual(6)
36+
})
37+
38+
test('test getMetrics', async () => {
39+
//check success response
40+
const metrics = await sdkClient.getMetrics(rsid)
41+
expect(metrics.length).toEqual(99)
42+
43+
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"test": "npm run lint && npm run unit-tests",
88
"lint": "eslint './src/**/*.js'",
99
"unit-tests": "jest --ci -w=2",
10+
"e2e": "jest --testRegex './e2e/e2e.js'",
1011
"generate-docs": "jsdoc2md -t ./docs/readme_template.md ./src/index.js > README.md"
1112
},
1213
"dependencies": {

0 commit comments

Comments
 (0)