Skip to content

Commit ee53e9d

Browse files
committed
Fix formatting & tests
1 parent 31b9185 commit ee53e9d

File tree

1 file changed

+63
-24
lines changed

1 file changed

+63
-24
lines changed

src/labs/ia-combo-box/ia-combo-box.test.ts

Lines changed: 63 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import type { IAComboBox } from './ia-combo-box';
66
import './ia-combo-box';
77

88
const BASIC_OPTIONS = [
9-
{ id: 'foo', text: 'Foo Option' },
10-
{ id: 'bar', text: 'Bar Option' },
11-
{ id: 'baz', text: 'Baz Option' },
12-
{ id: 'buzz', text: 'Buzz Option' },
9+
{ id: 'foo', text: 'Foo' },
10+
{ id: 'bar', text: 'Bar' },
11+
{ id: 'baz', text: 'Baz' },
12+
{ id: 'buzz', text: 'Buzz' },
1313
];
1414

1515
describe('IA Combo Box', () => {
@@ -166,9 +166,16 @@ describe('IA Combo Box', () => {
166166
});
167167

168168
test('"all" filtering preset turns off filtering entirely', async () => {
169-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} filter="all"></ia-combo-box>`);
170-
171-
const textInput = el.shadowRoot?.querySelector('#text-input') as HTMLInputElement;
169+
const el = await fixture<IAComboBox>(
170+
html`<ia-combo-box
171+
.options=${BASIC_OPTIONS}
172+
filter="all"
173+
></ia-combo-box>`,
174+
);
175+
176+
const textInput = el.shadowRoot?.querySelector(
177+
'#text-input',
178+
) as HTMLInputElement;
172179
expect(textInput).to.exist;
173180

174181
textInput.value = 'b';
@@ -181,9 +188,16 @@ describe('IA Combo Box', () => {
181188
});
182189

183190
test('"prefix" filtering preset works correctly', async () => {
184-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} filter="prefix"></ia-combo-box>`);
185-
186-
const textInput = el.shadowRoot?.querySelector('#text-input') as HTMLInputElement;
191+
const el = await fixture<IAComboBox>(
192+
html`<ia-combo-box
193+
.options=${BASIC_OPTIONS}
194+
filter="prefix"
195+
></ia-combo-box>`,
196+
);
197+
198+
const textInput = el.shadowRoot?.querySelector(
199+
'#text-input',
200+
) as HTMLInputElement;
187201
expect(textInput).to.exist;
188202

189203
textInput.value = 'b';
@@ -199,12 +213,19 @@ describe('IA Combo Box', () => {
199213
});
200214

201215
test('"suffix" filtering preset works correctly', async () => {
202-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} filter="suffix"></ia-combo-box>`);
203-
204-
const textInput = el.shadowRoot?.querySelector('#text-input') as HTMLInputElement;
216+
const el = await fixture<IAComboBox>(
217+
html`<ia-combo-box
218+
.options=${BASIC_OPTIONS}
219+
filter="suffix"
220+
></ia-combo-box>`,
221+
);
222+
223+
const textInput = el.shadowRoot?.querySelector(
224+
'#text-input',
225+
) as HTMLInputElement;
205226
expect(textInput).to.exist;
206227

207-
textInput.value = 'b';
228+
textInput.value = 'z';
208229
textInput.dispatchEvent(new InputEvent('input'));
209230
await el.updateComplete;
210231

@@ -216,9 +237,16 @@ describe('IA Combo Box', () => {
216237
});
217238

218239
test('"substring" filtering preset works correctly', async () => {
219-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} filter="substring"></ia-combo-box>`);
220-
221-
const textInput = el.shadowRoot?.querySelector('#text-input') as HTMLInputElement;
240+
const el = await fixture<IAComboBox>(
241+
html`<ia-combo-box
242+
.options=${BASIC_OPTIONS}
243+
filter="substring"
244+
></ia-combo-box>`,
245+
);
246+
247+
const textInput = el.shadowRoot?.querySelector(
248+
'#text-input',
249+
) as HTMLInputElement;
222250
expect(textInput).to.exist;
223251

224252
textInput.value = 'a';
@@ -233,9 +261,16 @@ describe('IA Combo Box', () => {
233261
});
234262

235263
test('"subsequence" filtering preset works correctly', async () => {
236-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} filter="subsequence"></ia-combo-box>`);
237-
238-
const textInput = el.shadowRoot?.querySelector('#text-input') as HTMLInputElement;
264+
const el = await fixture<IAComboBox>(
265+
html`<ia-combo-box
266+
.options=${BASIC_OPTIONS}
267+
filter="subsequence"
268+
></ia-combo-box>`,
269+
);
270+
271+
const textInput = el.shadowRoot?.querySelector(
272+
'#text-input',
273+
) as HTMLInputElement;
239274
expect(textInput).to.exist;
240275

241276
textInput.value = 'bz';
@@ -257,8 +292,10 @@ describe('IA Combo Box', () => {
257292
});
258293

259294
test('shows options in provided order when sort=false', async () => {
260-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} open></ia-combo-box>`);
261-
295+
const el = await fixture<IAComboBox>(
296+
html`<ia-combo-box .options=${BASIC_OPTIONS} open></ia-combo-box>`,
297+
);
298+
262299
const allOptionElmts = el.shadowRoot?.querySelectorAll('.option');
263300
expect(allOptionElmts?.length).to.equal(4);
264301
expect(allOptionElmts?.[0].textContent.trim()).to.equal('Foo');
@@ -268,8 +305,10 @@ describe('IA Combo Box', () => {
268305
});
269306

270307
test('shows options in lexicographic order when sort=true', async () => {
271-
const el = await fixture<IAComboBox>(html`<ia-combo-box .options=${BASIC_OPTIONS} sort open></ia-combo-box>`);
272-
308+
const el = await fixture<IAComboBox>(
309+
html`<ia-combo-box .options=${BASIC_OPTIONS} sort open></ia-combo-box>`,
310+
);
311+
273312
const allOptionElmts = el.shadowRoot?.querySelectorAll('.option');
274313
expect(allOptionElmts?.length).to.equal(4);
275314
expect(allOptionElmts?.[0].textContent.trim()).to.equal('Bar');

0 commit comments

Comments
 (0)