fix preview inputs and markup preview
This commit is contained in:
31
frontend/tests/nodeWidgetDefaults.test.mjs
Normal file
31
frontend/tests/nodeWidgetDefaults.test.mjs
Normal file
@@ -0,0 +1,31 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { buildDefaultWidgetValues, getDefaultWidgetValue } from '../src/nodeWidgetDefaults.js';
|
||||
|
||||
test('enum widget defaults honor opts.default instead of the first option', () => {
|
||||
assert.equal(
|
||||
getDefaultWidgetValue([['line', 'rectangle', 'circle', 'arrow'], { default: 'arrow' }]),
|
||||
'arrow',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildDefaultWidgetValues keeps non-data required widget defaults', () => {
|
||||
assert.deepEqual(
|
||||
buildDefaultWidgetValues({
|
||||
input: {
|
||||
required: {
|
||||
input: ['ANNOTATION_SOURCE', { label: 'Input' }],
|
||||
shape: [['line', 'rectangle', 'circle', 'arrow'], { default: 'arrow' }],
|
||||
stroke_color: ['STRING', { default: '#ff0000', color_picker: true }],
|
||||
stroke_width: ['INT', { default: 3 }],
|
||||
},
|
||||
},
|
||||
}),
|
||||
{
|
||||
shape: 'arrow',
|
||||
stroke_color: '#ff0000',
|
||||
stroke_width: 3,
|
||||
},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user