UNPKG

@hello.nrfcloud.com/proto

Version:

Documents the communication protocol between the hello.nrfcloud.com backend and the web application

51 lines (50 loc) 1.65 kB
function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import assert from 'node:assert/strict'; import { describe, it } from 'node:test'; import { validateWithTypeBox } from 'validator/validateWithTypeBox.js'; import { UpgradePath } from './FOTAJob.js'; var v = validateWithTypeBox(UpgradePath); void describe('UpgradePath', function() { void it('should accept an upgrade path with plain versions', function() { return assert.equal(hasError(v({ '2.0.0': 'APP*1e29dfa3*v2.0.1', '2.0.1': 'APP*cd5412d9*v2.0.2' })), false); }); void describe('support semver ranges', function() { var _loop = function(_i, _iter) { var range = _iter[_i]; void it(range, function() { return assert.equal(hasError(v(_define_property({}, "".concat(range, "2.0.0"), 'APP*1e29dfa3*v2.0.1'))), false); }); }; for(var _i = 0, _iter = [ '<', '<=', '>', '>=' ]; _i < _iter.length; _i++)_loop(_i, _iter); }); void describe('reject invalid upgrade paths', function() { void it('should reject an upgrade path with an invalid version', function() { return assert.equal(hasError(v({ foo: 'bar' })), true); }); }); }); var hasError = function(result) { return 'errors' in result; };