UNPKG

atlas-app-services-admin-api

Version:
61 lines (60 loc) 2.85 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { AtlasAppServicesClient } from './'; import dotenv from 'dotenv'; dotenv.config(); class ConsoleLogger { log(message, ...optionalParams) { console.log(`**** ConsoleLogger-LOG: ${message}`, ...optionalParams); } error(message, ...optionalParams) { console.error(`**** ConsoleLogger-ERROR: ${message}`, ...optionalParams); } debug(message, ...optionalParams) { console.debug(`**** ConsoleLogger-DEBUG: ${message}`, ...optionalParams); } } const logger = new ConsoleLogger(); describe('AtlasAppServicesClient', () => { let client; beforeEach(() => { // Create instances of the mocked classes const config = { publicKey: process.env.ATLAS_APP_SERVICES_PUBLIC_KEY, privateKey: process.env.ATLAS_APP_SERVICES_PRIVATE_KEY, baseUrl: process.env.ATLAS_APP_SERVICES_BASE_URL, groupId: process.env.ATLAS_APP_SERVICES_GROUP_ID, }; client = new AtlasAppServicesClient(config, logger); }); it('instance should be an instanceof AtlasAppServicesClient', () => { expect(client instanceof AtlasAppServicesClient).toBeTruthy(); }); it('should have a method initialize', () => { expect(client.initialize).toBeDefined(); }); describe('constructor', () => { it('should create an instance of the client', () => { expect(client).toBeDefined(); expect(client).toBeInstanceOf(AtlasAppServicesClient); }); }); describe('call AppsApi and get valid result', () => { it('should initialize the client successfully', () => __awaiter(void 0, void 0, void 0, function* () { const client_app_id_Result = process.env.ATLAS_APP_SERVICES_APP_ID; yield client.initialize(); const atlasAppsApi = yield client.atlasAppsApi(); const appsArray = yield atlasAppsApi.adminListApplications(client.groupId, "atlas"); expect(appsArray).toBeDefined(); expect(appsArray.data).toBeDefined(); expect(appsArray.data[0].client_app_id).toBe(client_app_id_Result); }), 10000); }); });