update
This commit is contained in:
26
test/endpoint-utils.test.js
Normal file
26
test/endpoint-utils.test.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const EndpointUtils = require('../src/helper/endpointUtils.js');
|
||||
|
||||
test('generateMenuUtilsData returns helpers and compatibility options', () => {
|
||||
const endpointUtils = new EndpointUtils();
|
||||
const data = endpointUtils.generateMenuUtilsData('measurement', {
|
||||
customCheck: 'function(value) { return !!value; }',
|
||||
});
|
||||
|
||||
assert.equal(data.nodeName, 'measurement');
|
||||
assert.equal(typeof data.helpers.validateRequired, 'string');
|
||||
assert.equal(typeof data.helpers.customCheck, 'string');
|
||||
assert.equal(data.options.autoLoadLegacy, true);
|
||||
});
|
||||
|
||||
test('generateMenuUtilsBootstrap points to data and legacy endpoints', () => {
|
||||
const endpointUtils = new EndpointUtils();
|
||||
const script = endpointUtils.generateMenuUtilsBootstrap('measurement');
|
||||
|
||||
assert.match(script, /menuUtilsData\.json/);
|
||||
assert.match(script, /menuUtils\.legacy\.js/);
|
||||
assert.match(script, /window\.EVOLV\.nodes/);
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ test('process format emits message with changed fields only', () => {
|
||||
assert.deepEqual(first.payload, { a: 1, b: 2 });
|
||||
|
||||
const second = out.formatMsg({ a: 1, b: 2 }, config, 'process');
|
||||
assert.equal(second, undefined);
|
||||
assert.equal(second, null);
|
||||
|
||||
const third = out.formatMsg({ a: 1, b: 3, c: { x: 1 } }, config, 'process');
|
||||
assert.deepEqual(third.payload, { b: 3, c: JSON.stringify({ x: 1 }) });
|
||||
|
||||
Reference in New Issue
Block a user