Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bearfriend committed Jun 21, 2023
1 parent 33a3df5 commit 280f549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/tag-list/tag-list-item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const TagListItemMixin = superclass => class extends LocalizeCoreElement(
}

_renderTag(tagContent, options = {}) {
this._displayText = options.displayText || tagContent?.constructor === String ? tagContent : '';
this._displayText = options.displayText || (tagContent?.constructor === String ? tagContent : '');

const buttonText = this.localize('components.tag-list.clear', { value: this._displayText });

Expand Down
18 changes: 18 additions & 0 deletions components/tag-list/test/tag-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@ describe('d2l-tag-list-item', () => {
});
});

describe('display text', () => {
it('should default to tagContent', async() => {
const elem = await fixture(basicFixture);
await waitUntil(() => elem._items, 'List items did not become ready');

const child = elem.children[1];
expect(child._displayText).to.be.equal('Another Tag');
});

it('should be set when provided', async() => {
const elem = await fixture(basicFixture);
await waitUntil(() => elem._items, 'List items did not become ready');

const child = elem.children[3];
expect(child._displayText).to.be.equal('Tag');
});
});

describe('clearable items', () => {
it('should dispatch expected event when clicked', async() => {
const elem = await fixture(clearableFixture);
Expand Down

0 comments on commit 280f549

Please sign in to comment.