Skip to content

Commit

Permalink
test: adjust test to use code instead of key
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Dec 27, 2023
1 parent 01a4845 commit 9e92ea4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {describe, expect, it, vi} from 'vitest';
import {AbortError, captureUid, registerUidCapture} from '../src/index.js';

const startEvent = new KeyboardEvent('keydown', {altKey: true, shiftKey: true, ctrlKey: true, key: 'U'});
const endEvent = new KeyboardEvent('keydown', {altKey: true, shiftKey: true, ctrlKey: true, key: 'D'});
const startEvent = new KeyboardEvent('keydown', {altKey: true, shiftKey: true, ctrlKey: true, code: 'KeyU'});
const endEvent = new KeyboardEvent('keydown', {altKey: true, shiftKey: true, ctrlKey: true, code: 'KeyD'});

const sendUid = (uid : string) => {
window.dispatchEvent(startEvent);

for (const char of uid) {
window.dispatchEvent(new KeyboardEvent('keydown', {key: char}));
window.dispatchEvent(new KeyboardEvent('keydown', {code: `Key${char.toUpperCase()}`}));
}

window.dispatchEvent(endEvent);
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('register', () => {
vi.advanceTimersByTime(1000);

for (const char of 'aabbccdd') {
window.dispatchEvent(new KeyboardEvent('keydown', {key: char}));
window.dispatchEvent(new KeyboardEvent('keydown', {code: `Key${char.toUpperCase()}`}));
}

window.dispatchEvent(endEvent);
Expand Down

0 comments on commit 9e92ea4

Please sign in to comment.