-
Notifications
You must be signed in to change notification settings - Fork 502
Expand file tree
/
Copy pathserver-test.js
More file actions
78 lines (67 loc) · 1.54 KB
/
Copy pathserver-test.js
File metadata and controls
78 lines (67 loc) · 1.54 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var simple = require('simple-mock')
var test = require('tap').test
var path = require('path')
var hapiPlugin = require('../../server')
var serverMock = {
register: simple.stub().callbackWith(null),
ext: simple.stub()
}
require('npmlog').level = 'error'
test('server', function (t) {
hapiPlugin.register(serverMock, {
paths: {
data: '.'
},
plugins: [],
app: {}
}, function (error) {
t.error(error)
t.end()
})
})
test('does not modify the passed options object', function (t) {
var options = {
db: {
url: 'http://admin:admin@localhost:5984'
},
plugins: [],
app: {}
}
hapiPlugin.register(serverMock, options, function () {})
t.is(options.db.url, 'http://admin:admin@localhost:5984')
t.end()
})
test('error on register is passed to callback', function (t) {
var serverErrorMock = {
register: simple.stub().callbackWith(new Error()),
ext: simple.stub()
}
hapiPlugin.register(serverErrorMock, {
paths: {
data: '.'
},
plugins: [],
app: {}
}, function (error, server, options) {
t.ok(error)
t.end()
})
})
test('application root with valid server module', function (t) {
var options = {
paths: {
public: 'public'
},
plugins: [],
app: {}
}
var savedPath = process.cwd()
t.tearDown(function () {
process.chdir(savedPath)
})
process.chdir(path.resolve(__dirname, '../fixture/app-dir-with-server/'))
hapiPlugin.register(serverMock, options, function (error, server, options) {
t.error(error)
t.end()
})
})