@mytmpvpn/mytmpvpn-client
Version:
MyTmpVpn Client Library
42 lines (41 loc) • 2.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const appconfig = require("../src/appconfig");
const common_1 = require("./common");
describe('Testing listVpn APIs', () => {
var client;
const appConfig = appconfig.loadDefaultAppConfig();
const userProfile = (0, common_1.createUserProfile)();
beforeAll(async () => {
client = await (0, common_1.createAuthUser)(appConfig, userProfile);
}, 600000);
afterAll(async () => {
await (0, common_1.deleteCleanUpAllAndDeleteAuthUser)(client, appConfig, userProfile);
}, 600000);
it("should list empty set of vpns", async () => {
const vpns = await client.listVpns();
expect(vpns).toBeDefined();
expect(vpns).toHaveLength(0);
});
it("should list vpns correctly", async () => {
const expectedVpns = [];
const vpnConfig = (0, common_1.getGoodPeanutsConfig)(await client.getVpnConfigLimits());
// 1 vpn, pageSize=2
expectedVpns.push(await client.createVpn(common_1.VPN_REGION, vpnConfig));
let vpnList = await client.listVpns(2);
expect(vpnList.map(vpn => vpn.vpnId).reverse()).toEqual(expectedVpns.map(vpn => vpn.vpnId));
// 2 vpns, pageSize=2
expectedVpns.push(await client.createVpn(common_1.VPN_REGION, vpnConfig));
vpnList = await client.listVpns(2);
expect(vpnList.map(vpn => vpn.vpnId).reverse()).toEqual(expectedVpns.map(vpn => vpn.vpnId));
// 3 vpns, pageSize=2
expectedVpns.push(await client.createVpn(common_1.VPN_REGION, vpnConfig));
vpnList = await client.listVpns(2);
expect(vpnList.map(vpn => vpn.vpnId).reverse()).toEqual(expectedVpns.map(vpn => vpn.vpnId));
// Let's make sure listVpns() with default pageSize also works
expectedVpns.push(await client.createVpn(common_1.VPN_REGION, vpnConfig));
vpnList = await client.listVpns();
expect(vpnList.map(vpn => vpn.vpnId).reverse()).toEqual(expectedVpns.map(vpn => vpn.vpnId));
await (0, common_1.cleanUpAll)(client);
});
});