Runs the test that asserts that we handle modifier keys correctly.
(
context: {
nextKeyEvent: KeyboardEvent;
prevKeyEvent: KeyboardEvent;
},
modifier: ListKeyManagerModifierKey,
)
| 500 | |
| 501 | /** Runs the test that asserts that we handle modifier keys correctly. */ |
| 502 | function runModifierKeyTest( |
| 503 | context: { |
| 504 | nextKeyEvent: KeyboardEvent; |
| 505 | prevKeyEvent: KeyboardEvent; |
| 506 | }, |
| 507 | modifier: ListKeyManagerModifierKey, |
| 508 | ) { |
| 509 | const initialActiveIndex = keyManager.activeItemIndex; |
| 510 | const spy = jasmine.createSpy('change spy'); |
| 511 | keyManager.change.subscribe(spy); |
| 512 | |
| 513 | expect(context.nextKeyEvent.defaultPrevented).toBe(false); |
| 514 | expect(context.prevKeyEvent.defaultPrevented).toBe(false); |
| 515 | |
| 516 | Object.defineProperty(context.nextKeyEvent, modifier, {get: () => true}); |
| 517 | Object.defineProperty(context.prevKeyEvent, modifier, {get: () => true}); |
| 518 | |
| 519 | keyManager.onKeydown(context.nextKeyEvent); |
| 520 | expect(context.nextKeyEvent.defaultPrevented).toBe(false); |
| 521 | expect(keyManager.activeItemIndex).toBe(initialActiveIndex); |
| 522 | expect(spy).not.toHaveBeenCalled(); |
| 523 | |
| 524 | keyManager.onKeydown(context.prevKeyEvent); |
| 525 | expect(context.prevKeyEvent.defaultPrevented).toBe(false); |
| 526 | expect(keyManager.activeItemIndex).toBe(initialActiveIndex); |
| 527 | expect(spy).not.toHaveBeenCalled(); |
| 528 | } |
| 529 | }); |
| 530 | |
| 531 | describe('programmatic focus', () => { |
no test coverage detected