Skip to content

Commit

Permalink
refactor based from review
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkithelegendarypokemonster committed Jan 10, 2025
1 parent d75c74e commit 709c69b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/devextreme/js/__internal/ui/m_tag_box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,7 @@ const TagBox = (SelectBox as any).inherit({
break;
case 'dataSource':
this._synchronizeTagsWithData();
this.callBase(args);
this._renderTags();
break;
case 'maxFilterQueryLength':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Guid from 'core/guid';

import { TextEditorLabel } from '__internal/ui/text_box/m_text_editor.label';

import 'generic_light.css!';
// import 'generic_light.css!';

QUnit.testStart(() => {
const markup =
Expand Down Expand Up @@ -6708,36 +6708,30 @@ QUnit.module('dataSource integration', moduleSetup, () => {
this.tagBox = this.$tagBox.dxTagBox('instance');
}
}, () => {
QUnit.test('Tagbox should only render existing tags (T1253312)', function(assert) {
this.tagBox.option('dataSource', this.data.slice(0, 1));

assert.strictEqual(this.$tagBox.find(`.${TAGBOX_TAG_CLASS}`).length, 1, 'Only one tag is rendered after the dataSource is reduced.');
assert.strictEqual(this.$tagBox.find(`.${TAGBOX_TAG_CLASS}`).eq(0).text(), 'HD Video Player', 'Rendered tags match the updated dataSource.');
});
QUnit.test('Tagbox updates value option (T1253312)', function(assert) {
assert.deepEqual(this.tagBox.option('selectedItems'), this.data, 'Initially, selectedItems contains both items from the dataSource.');

QUnit.test('Tagbox updates value and selectedItems (T1253312)', function(assert) {
this.tagBox.option('dataSource', this.data.slice(0, 1));

assert.deepEqual(this.tagBox.option('selectedItems'), this.data.slice(0, 1), 'selectedItems match the updated dataSource.');
assert.deepEqual(this.tagBox.option('value'), [1], 'value is updated based on the new dataSource.');
assert.deepEqual(this.tagBox.option('value'), [1], 'value is updated based on the new dataSource');
});

QUnit.test('Tagbox shouldnt render any tags if dataSource is updated to either null or empty (T1253312)', function(assert) {
this.tagBox.option('dataSource', []);

assert.strictEqual(this.$tagBox.find(`.${TAGBOX_TAG_CLASS}`).length, 0, 'No tags are rendered after empty dataSource');
QUnit.test('Tagbox updates selectedItems option (T1253312)', function(assert) {
assert.deepEqual(this.tagBox.option('selectedItems'), this.data, 'Initially, selectedItems contains both items from the dataSource.');

this.tagBox.option('dataSource', null);
this.tagBox.option('dataSource', this.data.slice(0, 1));

assert.strictEqual(this.$tagBox.find(`.${TAGBOX_TAG_CLASS}`).length, 0, 'No tags are rendered after null dataSource');
assert.deepEqual(this.tagBox.option('selectedItems'), this.data.slice(0, 1), 'selectedItems match the updated dataSource');
});

QUnit.test('Tagbox should update its selectedItems and value to empty if dataSource is updated to empty or null (T1253312)', function(assert) {
QUnit.test('Tagbox should update its selectedItems and value to empty if dataSource is updated to empty (T1253312)', function(assert) {
this.tagBox.option('dataSource', []);

assert.deepEqual(this.tagBox.option('selectedItems'), [], 'selectedItems is updated to empty array when dataSource is empty');
assert.deepEqual(this.tagBox.option('value'), [], 'value is updated to empty array when dataSource is empty');
});

QUnit.test('Tagbox should update its selectedItems and value to empty if dataSource is updated to null (T1253312)', function(assert) {
this.tagBox.option('dataSource', null);

assert.deepEqual(this.tagBox.option('selectedItems'), [], 'selectedItems is updated to empty array when dataSource is null');
Expand Down

0 comments on commit 709c69b

Please sign in to comment.