Skip to content

Commit

Permalink
Refactor test for events lockdown function
Browse files Browse the repository at this point in the history
  • Loading branch information
david0xd committed Mar 9, 2023
1 parent 0a4b5d2 commit bad541d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ describe('lockdown events security', () => {
it('should lockdown events and made event properties inaccessible', async () => {
executeLockdownEvents();

let resolvePromise: (value: unknown) => void;
const eventTarget = new EventTarget();

const promise = new Promise((resolve) => {
resolvePromise = resolve;
eventTarget.addEventListener('just-test-event', (eventObject) => {
// eslint-disable-next-line @typescript-eslint/unbound-method
resolve(eventObject.composedPath);
});
});

const eventTarget = new EventTarget();
eventTarget.addEventListener('just-test-event', (eventObject) => {
// eslint-disable-next-line @typescript-eslint/unbound-method
expect(eventObject.composedPath).toBeUndefined();
resolvePromise(true);
});
const testEvent = new Event('just-test-event');
eventTarget.dispatchEvent(testEvent);
await promise;

const result = await promise;
expect(result).toBeUndefined();
});
});

0 comments on commit bad541d

Please sign in to comment.