Browse Source

Add unit test for addAttribute and setAttributes

pull/6351/head
mohamedsalem401 2 years ago
parent
commit
f00e14cf66
  1. 37
      packages/core/test/specs/data_sources/dynamic_values/attributes.ts

37
packages/core/test/specs/data_sources/dynamic_values/attributes.ts

@ -74,8 +74,41 @@ describe('TraitDataVariable', () => {
testAttribute(cmp, 'dynamicAttribute', 'changed-value');
});
// TODO: Decide what to do about watching traits
test.skip('dynamic attributes should listen to the latest dynamic value', () => {
test('(Component.setAttributes) dynamic attributes should listen to the latest dynamic value', () => {
const dataSource = {
id: 'ds_id',
records: [
{ id: 'id1', value: 'test-value' },
{ id: 'id2', value: 'test-value' },
],
};
dsm.add(dataSource);
const attributes = {
...staticAttributes,
dynamicAttribute: {
type: DataVariableType,
defaultValue: 'default',
path: 'ds_id.id1.value',
},
};
const cmp = cmpRoot.append({
tagName: 'input',
attributes,
})[0];
cmp.setAttributes({
dynamicAttribute: {
type: DataVariableType,
defaultValue: 'default',
path: 'ds_id.id2.value',
},
});
changeDataSourceValue(dsm);
testAttribute(cmp, 'dynamicAttribute', 'test-value');
});
test('(Component.addAttributes) dynamic attributes should listen to the latest dynamic value', () => {
const dataSource = {
id: 'ds_id',
records: [

Loading…
Cancel
Save