Browse Source

test: add traint input update coverage

ci/dependabot
danstarns 2 years ago
parent
commit
adb0544089
  1. 84
      test/specs/data_sources/index.ts

84
test/specs/data_sources/index.ts

@ -317,33 +317,69 @@ describe('DataSourceManager', () => {
fixtures.appendChild(wrapperEl.el); fixtures.appendChild(wrapperEl.el);
}); });
test('component initializes with data-variable trait input', () => { describe('input component', () => {
const inputDataSource: DataSourceProps = { test('component initializes with trait data-variable on input component', () => {
id: 'test-input', const inputDataSource: DataSourceProps = {
records: [{ id: 'id1', value: 'test-value' }], id: 'test-input',
}; records: [{ id: 'id1', value: 'test-value' }],
dsm.add(inputDataSource); };
dsm.add(inputDataSource);
const cmp = cmpRoot.append({
tagName: 'input',
traits: [
'name',
'type',
{
type: 'text',
label: 'Value',
name: 'value',
value: {
type: 'data-variable',
value: 'default',
path: 'test-input.id1.value',
},
},
],
})[0];
const cmp = cmpRoot.append({ const input = cmp.getEl();
tagName: 'input', expect(input?.getAttribute('value')).toBe('test-value');
traits: [ });
'name',
'type', test('component updates with trait data-variable on input component', () => {
{ const inputDataSource: DataSourceProps = {
type: 'text', id: 'test-input',
label: 'Value', records: [{ id: 'id1', value: 'test-value' }],
name: 'value', };
value: { dsm.add(inputDataSource);
type: 'data-variable',
value: 'default', const cmp = cmpRoot.append({
path: 'test-input.id1.value', tagName: 'input',
traits: [
'name',
'type',
{
type: 'text',
label: 'Value',
name: 'value',
value: {
type: 'data-variable',
value: 'default',
path: 'test-input.id1.value',
},
}, },
}, ],
], })[0];
})[0];
const input = cmp.getEl(); const input = cmp.getEl();
expect(input?.getAttribute('value')).toBe('test-value'); expect(input?.getAttribute('value')).toBe('test-value');
const testDs = dsm.get('test-input');
testDs.getRecord('id1')?.set({ value: 'new-value' });
expect(input?.getAttribute('value')).toBe('new-value');
});
}); });
}); });

Loading…
Cancel
Save