diff --git a/lib/models/device-type.ts b/lib/models/device-type.ts index a2f326ff4..8f7e12cc0 100644 --- a/lib/models/device-type.ts +++ b/lib/models/device-type.ts @@ -30,7 +30,7 @@ const traversingCompile = ( initial: Contract, path: string[], ): Contract => { - let interpolated: Contract = { ...initial } + let interpolated: Contract = { ...initial }; for (const partialKey of Object.keys(partials)) { const current = partials[partialKey]; if (Array.isArray(current)) { @@ -52,7 +52,7 @@ const traversingCompile = ( } } return interpolated; -} +}; const interpolatedPartials = (contract: Contract): Contract => { if (contract.partials) { @@ -417,7 +417,9 @@ const getDeviceTypeModel = function (deps: InjectedDependenciesParam) { $select: 'contract', }); if (!contract) { - throw new Error(`Could not find contract for device type ${deviceTypeSlug}`); + throw new Error( + `Could not find contract for device type ${deviceTypeSlug}`, + ); } return interpolatedPartials(contract); }, @@ -459,7 +461,10 @@ const getDeviceTypeModel = function (deps: InjectedDependenciesParam) { } const installMethod = calculateInstallMethod(contract); const interpolatedDeviceType = interpolatedPartials(contract); - const interpolatedHostOS = interpolatedPartials({...cloneDeep(BalenaOS), ...interpolatedDeviceType}); + const interpolatedHostOS = interpolatedPartials({ + ...cloneDeep(BalenaOS), + ...interpolatedDeviceType, + }); return interpolatedHostOS.partials?.[installMethod]; }, diff --git a/lib/types/device-type-json.ts b/lib/types/device-type-json.ts index b61f914fc..8eae44b05 100644 --- a/lib/types/device-type-json.ts +++ b/lib/types/device-type-json.ts @@ -6,7 +6,7 @@ export interface DeviceType { slug: string; name: string; aliases: string[]; - + arch: string; state?: string; community?: boolean; diff --git a/tests/integration/models/device-type.spec.ts b/tests/integration/models/device-type.spec.ts index 4b3d6987e..5e046cdd3 100644 --- a/tests/integration/models/device-type.spec.ts +++ b/tests/integration/models/device-type.spec.ts @@ -100,6 +100,12 @@ describe('Device Type model', function () { ); expect(partials).to.be.an('object'); expect(Object.keys(partials)).to.not.have.length(0); + expect(partials) + .to.have.property('partials') + .to.have.property('bootDevice'); + expect(partials?.partials?.bootDevice[0]).to.equal( + 'Connect power to the Raspberry Pi 2', + ); }); }); @@ -110,6 +116,14 @@ describe('Device Type model', function () { ); expect(partials).to.be.an('Array'); expect(partials).to.not.have.length(0); + expect(partials).to.eql([ + 'Insert the sdcard to the host machine.', + 'Write the balenaOS file you downloaded to the sdcard. We recommend using Etcher.', + 'Wait for writing of balenaOS to complete.', + 'Remove the sdcard from the host machine.', + 'Insert the freshly flashed sdcard into the Raspberry Pi 2.', + 'Connect power to the Raspberry Pi 2 to boot the device.', + ]); }); });