123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- var should = require("should")
- var request = require('request')
- var path = require('path')
- var harp = require('../')
- describe("headers", function(){
- var projectPath = path.join(__dirname, "apps/headers")
- var port = 8901
- before(function(done){
- harp.server(projectPath, { port: port }, done)
- })
- // static
- it("should be correct with a valid CSS file", function(done){
- request("http://localhost:" + port + "/valid-css.css", function(e,r,b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid HTML file", function(done){
- request("http://localhost:" + port + "/valid-html.html", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid JS file", function(done){
- request("http://localhost:" + port + "/valid-js.js", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "application/javascript")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- // valid
- it("should be correct with a valid Jade file", function(done){
- request("http://localhost:" + port + "/valid-jade.html", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid EJS file", function(done){
- request("http://localhost:" + port + "/valid-ejs.html", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid Markdown file", function(done){
- request("http://localhost:" + port + "/valid-markdown.html", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid CoffeeScript file", function(done){
- request("http://localhost:" + port + "/valid-coffee.js", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "application/javascript")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid LESS file", function(done){
- request("http://localhost:" + port + "/valid-less.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid Stylus file", function(done){
- request("http://localhost:" + port + "/valid-styl.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid SCSS file", function(done){
- request("http://localhost:" + port + "/valid-scss.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with a valid Sass file", function(done){
- request("http://localhost:" + port + "/valid-sass.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- // invalid
- it("should be correct with an invalid EJS file", function(done){
- request("http://localhost:" + port + "/invalid-ejs.html", function(e, r, b){
- r.statusCode.should.eql(500)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with an invalid Jade file", function(done){
- request("http://localhost:" + port + "/invalid-jade.html", function(e, r, b){
- r.statusCode.should.eql(500)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with an invalid LESS file", function(done){
- request("http://localhost:" + port + "/invalid-less.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with an invalid Stylus file", function(done){
- request("http://localhost:" + port + "/invalid-styl.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with an invalid SCSS file", function(done){
- request("http://localhost:" + port + "/invalid-scss.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct with an invalid Sass file", function(done){
- request("http://localhost:" + port + "/invalid-sass.css", function(e, r, b){
- r.statusCode.should.eql(200)
- r.headers.should.have.property("content-type", "text/css; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- // TODO: This should change to javascript error file.
- it("should be correct with an invalid CoffeeScript file", function(done){
- request("http://localhost:" + port + "/invalid-coffee.js", function(e, r, b){
- r.statusCode.should.eql(500)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- // direct
- it("should be correct when Jade file requested", function(done){
- request("http://localhost:" + port + "/valid-jade.jade", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when EJS file requested", function(done){
- request("http://localhost:" + port + "/valid-ejs.ejs", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when Markdown file requested", function(done){
- request("http://localhost:" + port + "/valid-markdown.md", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when CoffeeScript file requested", function(done){
- request("http://localhost:" + port + "/valid-coffee.coffee", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when LESS file requested", function(done){
- request("http://localhost:" + port + "/valid-less.less", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when Stylus file requested", function(done){
- request("http://localhost:" + port + "/valid-styl.styl", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when SCSS file requested", function(done){
- request("http://localhost:" + port + "/valid-scss.scss", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- // missing pages
- it("should be correct when missing css file", function(done){
- request("http://localhost:" + port + "/missing.css", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when missing html file", function(done){
- request("http://localhost:" + port + "/missing.html", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- it("should be correct when missing js file", function(done){
- request("http://localhost:" + port + "/missing.js", function(e, r, b){
- r.statusCode.should.eql(404)
- r.headers.should.have.property("content-type", "text/html; charset=UTF-8")
- r.headers.should.have.property("content-length")
- done()
- })
- })
- })
|