Skip to content

Commit 3bd6ede

Browse files
committed
fixup! test(cdk-experimental/ui-patterns): listbox navigation tests
1 parent da5d261 commit 3bd6ede

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/cdk-experimental/ui-patterns/listbox/listbox.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,23 @@ describe('Listbox Pattern', () => {
132132
listbox.onKeydown(event);
133133
expect(listbox.inputs.activeIndex()).toBe(0);
134134
});
135+
136+
it('should navigate to the first option on Home', () => {
137+
const event = createKeyboardEvent('keydown', 36, 'Home');
138+
const {listbox, options} = getDefaultPatterns({
139+
activeIndex: signal(8),
140+
});
141+
expect(listbox.inputs.activeIndex()).toBe(8);
142+
listbox.onKeydown(event);
143+
expect(listbox.inputs.activeIndex()).toBe(0);
144+
});
145+
146+
it('should navigate to the last option on End', () => {
147+
const event = createKeyboardEvent('keydown', 35, 'End');
148+
const {listbox, options} = getDefaultPatterns();
149+
expect(listbox.inputs.activeIndex()).toBe(0);
150+
listbox.onKeydown(event);
151+
expect(listbox.inputs.activeIndex()).toBe(options().length - 1);
152+
});
135153
});
136154
});

0 commit comments

Comments
 (0)