atlas-app-services-admin-api
Version:
OpenAPI client for Atlas App Services Admin API
66 lines (65 loc) • 3.09 kB
JavaScript
;
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const _1 = require("./");
const dotenv_1 = __importDefault(require("dotenv"));
dotenv_1.default.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 _1.AtlasAppServicesClient(config, logger);
});
it('instance should be an instanceof AtlasAppServicesClient', () => {
expect(client instanceof _1.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(_1.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);
});
});