import nrfdlModule, { Device, // @ts-ignore nrfdlModule Is not a module } from '../../../../index'; import { validateSchema } from '../common/helpers'; require('../../../../jasmine_shared.js'); describe('[get device core info tests]', () => { let context = 0; let devicesList: Device[] = []; jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000; beforeAll(async () => { context = nrfdlModule.createContext(); const result = await nrfdlModule.enumerate(context); devicesList = result .filter((el: Device) => el.traits.jlink) .map(async (device: Device) => { await nrfdlModule.deviceControlRecover(context, device.id); return device; }); devicesList = await Promise.all(devicesList); }); afterAll(() => { nrfdlModule.releaseContext(context); }); it('Test get device core info', async () => { const devices = devicesList.slice(0, 1); expect(devices.length).toEqual(1); const layout = await nrfdlModule.getDeviceCoreInfo(context, devices[0].id); const schemaValid = await validateSchema('#/definitions/DeviceCoreInfo', layout, true); expect(schemaValid).toBe(true); }); it('Test get device core info from modem', async () => { const result = await nrfdlModule.enumerate(context); let devices = result.filter((el: Device) => { return el.traits.jlink && el.jlink.boardVersion === 'PCA10090'; }); devices = devices.slice(0, 1); expect(devices.length).toEqual(1); // reset protected device // await nrfdlModule.deviceControlRecover(context, devices[0].id); // await nrfdlModule.deviceControlRecover(context, devices[0].id, 'NRFDL_DEVICE_CORE_APPLICATION'); const info_application = await nrfdlModule.getDeviceCoreInfo( context, devices[0].id, 'NRFDL_DEVICE_CORE_APPLICATION' ); // not required to test: Chun // core is protected and not possible to recover on 91DK // const info_modem = await nrfdlModule.getDeviceCoreInfo( // context, // devices[0].id, // 'NRFDL_DEVICE_CORE_MODEM' // ); expect(info_application.codeSize).toBeDefined(); // expect(info_modem.codeSize).toBeDefined(); // expect(info_application.codeSize === info_modem.codeSize).toBeFalse(); const schemaAppValid = await validateSchema('#/definitions/DeviceCoreInfo', info_application); expect(schemaAppValid).toBe(true); }); });