Permalink
Browse files

testing for HEAD requests

  • Loading branch information...
1 parent cf06169 commit 5086158228e852be887a5c353a1ae190947d0a1d @dcolens dcolens committed Feb 10, 2012
Showing with 16 additions and 0 deletions.
  1. +16 −0 test/rest.coffee
View
@@ -71,7 +71,23 @@ module.exports = testCase
fetch 'GET', @port, "/doc/#{@name}", null, (res, data) ->
test.strictEqual(res.statusCode, 404)
test.done()
+
+ 'return 404 and empty body when on HEAD on a nonexistant document': (test) ->
+ fetch 'HEAD', @port, "/doc/#{@name}", null, (res, data) ->
+ test.strictEqual res.statusCode, 404
+ test.strictEqual data, ''
+ test.done()
+ 'return 200, empty body, version and type when on HEAD on a document': (test) ->
+ @model.create @name, 'simple', =>
+ @model.applyOp @name, {v:0, op:{position: 0, text: 'Hi'}}, =>
+ fetch 'HEAD', @port, "/doc/#{@name}", null, (res, data, headers) ->
+ test.strictEqual res.statusCode, 200
+ test.strictEqual headers['x-ot-version'], '1'
+ test.strictEqual headers['x-ot-type'], 'simple'
+ test.strictEqual data, ''
+ test.done()
+
'GET a document returns the document snapshot': (test) ->
@model.create @name, 'simple', =>
@model.applyOp @name, {v:0, op:{position: 0, text: 'Hi'}}, =>

0 comments on commit 5086158

Please sign in to comment.