-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.js
More file actions
38 lines (35 loc) · 725 Bytes
/
test.js
File metadata and controls
38 lines (35 loc) · 725 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
37
38
import test from 'ava'
import eventstop from './src'
test('main', t => {
const {on, emit} = eventstop()
let yourName
const off = on('hola', name => {
yourName = name
})
emit('hola', 'taki')
t.is(yourName, 'taki')
off()
emit('hola', 'mitsuha')
t.is(yourName, 'taki')
})
test('once', t => {
const {once, emit} = eventstop()
let yourName
const off = once('hola', name => {
yourName = name
})
emit('hola', 'taki')
t.is(yourName, 'taki')
emit('hola', 'mitsuha')
t.is(yourName, 'taki')
})
test('wildcard', t => {
const {on, emit} = eventstop()
let yourName
on('*', (type, name) => {
t.is(type, 'foo')
yourName = name
})
emit('foo', 'taki')
t.is(yourName, 'taki')
})