Skip to content

Commit 3b5d103

Browse files
author
Martin Martinez Rivera
committed
Tests now read the file instead of comparing againts fixed string
1 parent 469714c commit 3b5d103

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

‎test/errors.js‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,26 @@ describe('Error page tests', function() {
4040

4141

4242
describe('Error page test', function() {
43+
var file404 = 'errorPages/404.html';
44+
function defaultErrorPage(filepath, expected) {
45+
var handler = function (res) {
46+
var errorFile = read(filepath);
47+
if (res.text === errorFile && !expected){
48+
console.log("Not default text");
49+
}
50+
};
51+
return handler;
52+
}
4353
it('Should return 404 custom page if flag set to true',
4454
function(done) {
45-
errorServer.get('/non-existent-file.html')
46-
.expect(/404 Error Page/)
55+
errorServer.get('non-existent-file.html')
56+
.expect(defaultErrorPage(file404, true))
4757
.expect(404, done);
4858
});
4959
it('Should return 404 default page if flag set to false',
5060
function(done) {
51-
function isDefaultErrorPage(customText) {
52-
var handler = function (res) {
53-
if (res.text.match(customText)){
54-
console.log("Not default text");
55-
}
56-
};
57-
return handler;
58-
}
59-
noErrorServer.get('/non-existent-file.html')
60-
.expect(isDefaultErrorPage('404 Error Page'))
61+
noErrorServer.get('non-existent-file.html')
62+
.expect(defaultErrorPage(file404, false))
6163
.expect(404, done);
6264
});
6365
});

0 commit comments

Comments
 (0)