forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors-test.js
More file actions
46 lines (41 loc) · 1.31 KB
/
errors-test.js
File metadata and controls
46 lines (41 loc) · 1.31 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
const path = require('path')
const { read, setupSupertestServer } = require('./../utils')
describe('Error pages', function () {
// LDP with error pages
const errorServer = setupSupertestServer({
root: path.join(__dirname, '../resources'),
errorPages: path.join(__dirname, '../resources/errorPages'),
webid: false
})
// LDP with no error pages
const noErrorServer = setupSupertestServer({
root: path.join(__dirname, '../resources'),
noErrorPages: true,
webid: false
})
function defaultErrorPage (filepath, expected) {
const handler = function (res) {
const errorFile = read(filepath)
if (res.text === errorFile && !expected) {
console.log('Not default text')
}
}
return handler
}
describe('noErrorPages', function () {
const file404 = 'errorPages/404.html'
it('Should return 404 express default page', function (done) {
noErrorServer.get('/non-existent-file.html')
.expect(defaultErrorPage(file404, false))
.expect(404, done)
})
})
describe('errorPages set', function () {
const file404 = 'errorPages/404.html'
it('Should return 404 custom page if exists', function (done) {
errorServer.get('/non-existent-file.html')
.expect(defaultErrorPage(file404, true))
.expect(404, done)
})
})
})