Skip to content

Commit d0e011f

Browse files
Artur-claude
andcommitted
fix: fix multi-select-combo-box itemLabelGenerator tests
- Follow the existing pattern of counting overflow chip in total chip count - Use getChips() helper function consistently with existing tests - Access chip labels at correct indices (skip overflow chip at [0]) - Set proper width and await nextRender for consistent chip rendering All tests now pass: - select: 6/6 tests ✅ - combo-box: 8/8 tests ✅ - multi-select-combo-box: 9/9 tests ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 8e2a3b6 commit d0e011f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

packages/multi-select-combo-box/test/item-label-generator.test.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ describe('item-label-generator', () => {
1111
await nextRender();
1212
});
1313

14+
const getChips = (combo) => combo.querySelectorAll('vaadin-multi-select-combo-box-chip');
15+
1416
describe('basic functionality', () => {
15-
beforeEach(() => {
17+
beforeEach(async () => {
1618
comboBox.items = [
1719
{ id: 1, name: 'John', surname: 'Doe', age: 30 },
1820
{ id: 2, name: 'Jane', surname: 'Smith', age: 25 },
1921
{ id: 3, name: 'Bob', surname: 'Johnson', age: 35 },
2022
{ id: 4, name: 'Alice', surname: 'Williams', age: 28 },
2123
];
24+
comboBox.style.width = '100%';
25+
await nextRender();
2226
});
2327

2428
it('should generate labels using itemLabelGenerator in dropdown', async () => {
@@ -44,10 +48,10 @@ describe('item-label-generator', () => {
4448
];
4549
await nextRender();
4650

47-
const chips = comboBox.querySelectorAll('vaadin-multi-select-combo-box-chip[slot="chip"]');
48-
expect(chips.length).to.equal(2);
49-
expect(chips[0].label).to.equal('John Doe');
50-
expect(chips[1].label).to.equal('Jane Smith');
51+
const chips = getChips(comboBox);
52+
expect(chips.length).to.equal(3); // Includes overflow chip
53+
expect(chips[1].label).to.equal('John Doe');
54+
expect(chips[2].label).to.equal('Jane Smith');
5155
});
5256

5357
it('should filter items using generated labels', () => {
@@ -86,10 +90,10 @@ describe('item-label-generator', () => {
8690
];
8791
await nextRender();
8892

89-
const chips = comboBox.querySelectorAll('vaadin-multi-select-combo-box-chip[slot="chip"]');
90-
expect(chips.length).to.equal(2);
91-
expect(chips[0].label).to.equal('Doe, John (30)');
92-
expect(chips[1].label).to.equal('Johnson, Bob (35)');
93+
const chips = getChips(comboBox);
94+
expect(chips.length).to.equal(3); // Includes overflow chip
95+
expect(chips[1].label).to.equal('Doe, John (30)');
96+
expect(chips[2].label).to.equal('Johnson, Bob (35)');
9397
});
9498

9599
it('should update chips when itemLabelGenerator changes', async () => {
@@ -115,10 +119,10 @@ describe('item-label-generator', () => {
115119
comboBox.selectedItems = ['Apple', 'Orange'];
116120
await nextRender();
117121

118-
const chips = comboBox.querySelectorAll('vaadin-multi-select-combo-box-chip[slot="chip"]');
119-
expect(chips.length).to.equal(2);
120-
expect(chips[0].label).to.equal('Apple');
121-
expect(chips[1].label).to.equal('Orange');
122+
const chips = getChips(comboBox);
123+
expect(chips.length).to.equal(3); // Includes overflow chip
124+
expect(chips[1].label).to.equal('Apple');
125+
expect(chips[2].label).to.equal('Orange');
122126
});
123127

124128
it('should handle overflow chip with generated labels', async () => {

0 commit comments

Comments
 (0)