import Ajv from 'ajv'; // @ts-ignore nrfdlModule Is not a module import nrfdlModule, { AvailablePlugin } from '../../../index'; import { validateSchema } from './common/helpers'; require('../../../jasmine_shared.js'); /** * Test cases: * - get generated schemas from lib * * Test API: * - availablePlugins() * - getPluginSchema() * * Test Schema: * - AvailablePlugin */ describe('Test schema methods', () => { let context = 0; beforeAll(() => { context = nrfdlModule.createContext(); }); it('Get availablePlugins()', async () => { const plugins = nrfdlModule.availablePlugins(context); expect(plugins.length).toEqual(5); // count from .d.ts await Promise.all( plugins.map(async (plugin: AvailablePlugin) => { const schemaValid = await validateSchema('#/definitions/AvailablePlugin', plugin); expect(schemaValid).toBe(true); }) ); }); it('Get getPluginSchema() - jlink', () => { const schema = nrfdlModule.getPluginSchema(context, 'jlink'); const ajv = new Ajv(); ajv.addSchema(JSON.parse(schema)); }); it('Get getPluginSchema() - sdfu', () => { const schema = nrfdlModule.getPluginSchema(context, 'sdfu'); const ajv = new Ajv(); ajv.addSchema(JSON.parse(schema)); }); it('Get getPluginSchema() - mcuBoot', () => { const schema = nrfdlModule.getPluginSchema(context, 'mcuBoot'); const ajv = new Ajv(); ajv.addSchema(JSON.parse(schema)); }); });