@apillon/sdk
Version:
▶◀ Apillon SDK for NodeJS ▶◀
58 lines • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const rpc_1 = require("../modules/rpc/rpc");
const rpc_api_key_1 = require("../modules/rpc/rpc-api-key");
const helper_1 = require("./helpers/helper");
describe('Rpc Module tests', () => {
let rpc;
let apiKeyId;
beforeAll(() => {
rpc = new rpc_1.Rpc((0, helper_1.getConfig)());
});
test('Create new API key', async () => {
const apiKeyData = {
name: 'Test API Key',
description: 'Test Description',
};
const apiKey = await rpc.createApiKey(apiKeyData);
expect(apiKey).toBeInstanceOf(rpc_api_key_1.RpcApiKey);
expect(apiKey.name).toEqual(apiKeyData.name);
expect(apiKey.description).toEqual(apiKeyData.description);
expect(apiKey.uuid).toBeTruthy();
expect(apiKey.id).toBeTruthy();
apiKeyId = apiKey.id;
});
test('List API keys', async () => {
const { items } = await rpc.listApiKeys();
expect(items.length).toBeGreaterThanOrEqual(0);
items.forEach((apiKey) => {
expect(apiKey).toBeInstanceOf(rpc_api_key_1.RpcApiKey);
expect(apiKey.name).toBeTruthy();
expect(apiKey.uuid).toBeTruthy();
expect(apiKey.id).toBeTruthy();
});
});
test('Get specific API key', async () => {
const apiKey = await rpc.apiKey(apiKeyId).get();
expect(apiKey).toBeInstanceOf(rpc_api_key_1.RpcApiKey);
expect(apiKey.id).toEqual(apiKeyId);
expect(apiKey.urls.length).toBeGreaterThan(0);
});
test('List endpoints', async () => {
const endpoints = await rpc.listEndpoints();
expect(Array.isArray(endpoints)).toBeTruthy();
expect(endpoints.length).toBeGreaterThanOrEqual(0);
endpoints.forEach((endpoint) => {
expect(endpoint).toMatchObject({
id: expect.any(Number),
name: expect.any(String),
imageUrl: expect.any(String),
type: expect.any(String),
version: expect.any(String),
networkName: expect.any(String),
networkId: expect.any(Number),
});
});
});
});
//# sourceMappingURL=rpc.test.js.map