-
Notifications
You must be signed in to change notification settings - Fork 603
/
index.test-d.ts
40 lines (33 loc) · 723 Bytes
/
index.test-d.ts
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
39
40
import { expectAssignable, expectType } from 'tsd'
import Choo = require('.')
new Choo({})
new Choo()
new Choo({ cache: 100 })
new Choo({
cache: new Map()
})
new Choo({
cache: {
get: (id) => null,
set: (id, value) => expectType<any>(value)
}
})
const app = new Choo({
history: false,
href: true,
})
app.use((state, emitter) => {
state.title = 'choo choo'
emitter.on(state.events.DOMCONTENTLOADED, () => {
emitter.emit('example')
})
})
app.route('/', (state, emit) => {
expectAssignable<object>(state.params)
expectType<string>(state.href)
expectType<string>(state.route)
expectType<string>(state.title)
emit('example')
})
expectType<string>(app.toString('/'))
app.mount('body')