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
41
42
43
44
45
46
47
48
49
| 'use strict'
|
| const t = require('tap')
| const test = t.test
| const FindMyWay = require('../')
|
| test('handler should have the store object', t => {
| t.plan(1)
| const findMyWay = FindMyWay()
|
| findMyWay.on('GET', '/test', (req, res, params, store) => {
| t.is(store.hello, 'world')
| }, { hello: 'world' })
|
| findMyWay.lookup({ method: 'GET', url: '/test', headers: {} }, null)
| })
|
| test('find a store object', t => {
| t.plan(1)
| const findMyWay = FindMyWay()
| const fn = () => {}
|
| findMyWay.on('GET', '/test', fn, { hello: 'world' })
|
| t.deepEqual(findMyWay.find('GET', '/test'), {
| handler: fn,
| params: {},
| store: { hello: 'world' }
| })
| })
|
| test('update the store', t => {
| t.plan(2)
| const findMyWay = FindMyWay()
| var bool = false
|
| findMyWay.on('GET', '/test', (req, res, params, store) => {
| if (!bool) {
| t.is(store.hello, 'world')
| store.hello = 'hello'
| bool = true
| findMyWay.lookup({ method: 'GET', url: '/test', headers: {} }, null)
| } else {
| t.is(store.hello, 'hello')
| }
| }, { hello: 'world' })
|
| findMyWay.lookup({ method: 'GET', url: '/test', headers: {} }, null)
| })
|
|