-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
43 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import {test, expect} from 'vitest'; | ||
import {container, anchor} from './vitest.setup.js'; | ||
import {anchor} from './vitest.setup.js'; | ||
import oneEvent from './one-event.js'; | ||
|
||
test('should resolve after one event', async t => { | ||
const promise = oneEvent(container, 'a', 'click'); | ||
const promise = oneEvent('a', 'click'); | ||
anchor.click(); | ||
const event = await promise; | ||
expect(event).toBeInstanceOf(MouseEvent); | ||
}); | ||
|
||
test('should resolve with `undefined` after it’s aborted', async t => { | ||
const controller = new AbortController(); | ||
const promise = oneEvent(container, 'a', 'click', {signal: controller.signal}); | ||
const promise = oneEvent('a', 'click', {signal: controller.signal}); | ||
controller.abort(); | ||
|
||
const event = await promise; | ||
expect(event).toBeUndefined(); | ||
}); | ||
|
||
test('should resolve with `undefined` if the signal has already aborted', async t => { | ||
const promise = oneEvent(container, 'a', 'click', {signal: AbortSignal.abort()}); | ||
const promise = oneEvent('a', 'click', {signal: AbortSignal.abort()}); | ||
const event = await promise; | ||
expect(event).toBeUndefined(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters