-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbasic.js
More file actions
36 lines (27 loc) · 727 Bytes
/
basic.js
File metadata and controls
36 lines (27 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import test from 'tape'
import queueMicrotask from '../index.js'
test('basic test', t => {
t.plan(1)
queueMicrotask(() => t.pass('function was called'))
})
test('ensure correct ordering', t => {
t.plan(3)
let order = 0
queueMicrotask(() => {
t.equal(++order, 1)
queueMicrotask(() => t.equal(++order, 2))
})
setTimeout(() => t.equal(++order, 3), 0)
})
test('error handling', t => {
t.plan(2)
process.on('uncaughtException', onUncaughtException)
function onUncaughtException (err) {
t.equal(err.message, 'some error')
process.removeListener('uncaughtException', onUncaughtException)
}
queueMicrotask(() => {
t.pass('function called')
throw new Error('some error')
})
})