|
| 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 | +}) |
0 commit comments