-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
45 lines (35 loc) · 1.05 KB
/
test.js
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
'use strict'
const tap = require('tap')
const Fastify = require('fastify')
const fastifyWamp = require('./plugin')
const { test } = tap
test('Registers wampRouter | default options', t => {
t.plan(5)
const fastify = Fastify()
t.tearDown(fastify.close.bind(fastify))
fastify
.register(fastifyWamp)
.ready(err => {
t.error(err)
t.ok(fastify.hasDecorator('wampRouter'))
const { wampRouter: { options, port } } = fastify
t.equal(port, 3443)
t.equal(options.port, 3443)
t.deepEqual(options.realms, ['fastify.wamp.pubsub', 'fastify.wamp.rpc'])
})
})
test('Registers wampRouter | custom options', t => {
t.plan(4)
const fastify = Fastify()
t.tearDown(fastify.close.bind(fastify))
const routerOpts = { port: 3333, realms: ['custom.realm'] }
fastify
.register(fastifyWamp, routerOpts)
.ready(err => {
t.error(err)
t.ok(fastify.hasDecorator('wampRouter'))
const { wampRouter: { options, port } } = fastify
t.equal(port, 3333)
t.deepEqual(options, routerOpts)
})
})