forked from fmdkdd/sparkets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-http-server.coffee
65 lines (51 loc) · 1.33 KB
/
test-http-server.coffee
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
vows = require('vows')
assert = require('assert')
# Setup
http = require('http')
server = require('../build/server/httpServer').create()
port = 15000
# Tests
exports.suite = vows.describe('HTTP server')
exports.suite.addBatch
'':
topic: () ->
server.listen(port, @callback)
return
'GET /':
topic: () ->
http.get
host: 'localhost'
port: port
path: '/', (res) => @callback(null, res)
return
'should respond OK (200)': (err, res) ->
assert.isNull(err)
assert.equal(res.statusCode, 200)
'should serve HTML': (err, res) ->
assert.isNull(err)
assert.equal(res.headers['content-type'], 'text/html')
'GET /img/colorWheel.png':
topic: () ->
http.get
host: 'localhost'
port: port
path: '/img/colorWheel.png', (res) => @callback(null, res)
return
'should respond OK (200)': (err, res) ->
assert.isNull(err)
assert.equal(res.statusCode, 200)
'should serve PNG': (err, res) ->
assert.isNull(err)
assert.equal(res.headers['content-type'], 'image/png')
'GET /zorglub':
topic: () ->
http.get
host: 'localhost'
port: port
path: '/zorglub', (res) => @callback(null, res)
return
'should respond Not Found (404)': (err, res) ->
assert.isNull(err)
assert.equal(res.statusCode, 404)
teardown: () ->
server.close()