Skip to content

Commit

Permalink
test: update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
antv committed Aug 20, 2024
1 parent 644c5c2 commit 94b6ad5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/g6/__tests__/unit/utils/shortcut.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ describe('shortcut', () => {
expect(drag).toHaveBeenCalledTimes(1);
expect(drag.mock.calls[0][0].deltaX).toBe(10);
expect(drag.mock.calls[0][0].deltaY).toBe(0);

drag.mockClear();

// shift drag
emitter.emit(CommonEvent.KEY_DOWN, { key: 'Shift' });
emitter.emit(CommonEvent.DRAG, { deltaX: 10, deltaY: 0 });
emitter.emit(CommonEvent.KEY_UP, { key: 'Shift' });
expect(drag).toHaveBeenCalledTimes(0);

shortcut.unbindAll();
shortcut.bind(['Shift', 'drag'], drag);

emitter.emit(CommonEvent.KEY_DOWN, { key: 'Shift' });
emitter.emit(CommonEvent.DRAG, { deltaX: 10, deltaY: 0 });
emitter.emit(CommonEvent.KEY_UP, { key: 'Shift' });
expect(drag).toHaveBeenCalledTimes(1);
expect(drag.mock.calls[0][0].deltaX).toBe(10);
expect(drag.mock.calls[0][0].deltaY).toBe(0);
});

it('focus', () => {
Expand Down

0 comments on commit 94b6ad5

Please sign in to comment.