forked from sintaxi/harp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.js
124 lines (109 loc) · 3.88 KB
/
errors.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
var should = require("should")
var request = require('request')
var path = require("path")
var fs = require("fs")
var exec = require("child_process").exec
var harp = require("../")
describe("errors", function(){
describe("err-invalid-config", function(){
var projectPath = path.join(__dirname, "apps/err-invalid-config")
var outputPath = path.join(__dirname, "out/err-invalid-config")
var port = 8111
before(function(done){
harp.server(projectPath, { port: port }, function(){
done()
})
})
it("should get error message for invalid harp.json", function(done){
request('http://localhost:'+ port +'/', function (e, r, b) {
r.statusCode.should.eql(500)
b.should.include(harp.pkg.version)
harp.compile(projectPath, outputPath, function(error){
should.exist(error)
error.should.have.property("source")
error.should.have.property("dest")
error.should.have.property("filename")
error.should.have.property("message")
error.should.have.property("stack")
error.should.have.property("lineno")
done()
})
})
})
})
describe("err-invalid-data", function(){
var projectPath = path.join(__dirname, "apps/err-invalid-data")
var outputPath = path.join(__dirname, "out/err-invalid-data")
var port = 8112
before(function(done){
harp.server(projectPath, { port: port }, function(){
done()
})
})
it("should get error message for invalid _data.json", function(done){
request('http://localhost:'+ port +'/', function (e, r, b) {
r.statusCode.should.eql(500)
b.should.include(harp.pkg.version)
harp.compile(projectPath, outputPath, function(error){
should.exist(error)
error.should.have.property("source")
error.should.have.property("dest")
error.should.have.property("filename")
error.should.have.property("message")
error.should.have.property("stack")
error.should.have.property("lineno")
done()
})
})
})
})
describe("err-missing-public", function(){
var projectPath = path.join(__dirname, "apps/err-missing-public")
var outputPath = path.join(__dirname, "out/err-missing-public")
var port = 8113
before(function(done){
harp.server(projectPath, { port: port }, function(){
done()
})
})
it("should get error message for invalid _data.json", function(done){
request('http://localhost:'+ port +'/', function (e, r, b) {
r.statusCode.should.eql(500)
b.should.include(harp.pkg.version)
harp.compile(projectPath, outputPath, function(error){
should.exist(error)
error.should.have.property("source")
error.should.have.property("dest")
error.should.have.property("filename")
error.should.have.property("message")
error.should.have.property("stack")
error.should.have.property("lineno")
done()
})
})
})
})
describe("err-missing-public", function(){
var projectPath = path.join(__dirname, "apps/err-missing-404")
var outputPath = path.join(__dirname, "out/err-missing-404")
var port = 8114
before(function(done){
harp.server(projectPath, { port: port }, function(){
done()
})
})
it("should return proper mime type on 404 page", function(done){
request('http://localhost:'+ port +'/some/missing/path.css', function (e, r, b) {
r.statusCode.should.eql(404)
b.should.include(harp.pkg.version)
r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
done()
})
})
})
after(function(done){
exec("rm -rf " + path.join(__dirname, "out"), function(){
done()
})
})
})