Skip to content

Commit 5086158

Browse files
committed
testing for HEAD requests
1 parent cf06169 commit 5086158

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/rest.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,23 @@ module.exports = testCase
7171
fetch 'GET', @port, "/doc/#{@name}", null, (res, data) ->
7272
test.strictEqual(res.statusCode, 404)
7373
test.done()
74+
75+
'return 404 and empty body when on HEAD on a nonexistant document': (test) ->
76+
fetch 'HEAD', @port, "/doc/#{@name}", null, (res, data) ->
77+
test.strictEqual res.statusCode, 404
78+
test.strictEqual data, ''
79+
test.done()
7480

81+
'return 200, empty body, version and type when on HEAD on a document': (test) ->
82+
@model.create @name, 'simple', =>
83+
@model.applyOp @name, {v:0, op:{position: 0, text: 'Hi'}}, =>
84+
fetch 'HEAD', @port, "/doc/#{@name}", null, (res, data, headers) ->
85+
test.strictEqual res.statusCode, 200
86+
test.strictEqual headers['x-ot-version'], '1'
87+
test.strictEqual headers['x-ot-type'], 'simple'
88+
test.strictEqual data, ''
89+
test.done()
90+
7591
'GET a document returns the document snapshot': (test) ->
7692
@model.create @name, 'simple', =>
7793
@model.applyOp @name, {v:0, op:{position: 0, text: 'Hi'}}, =>

0 commit comments

Comments
 (0)