GettingDocsTests.coffee 972 B

12345678910111213141516171819202122232425262728293031323334
  1. sinon = require "sinon"
  2. chai = require("chai")
  3. chai.should()
  4. {ObjectId} = require "mongojs"
  5. DocstoreClient = require "./helpers/DocstoreClient"
  6. describe "Getting a doc", ->
  7. beforeEach (done) ->
  8. @project_id = ObjectId()
  9. @doc_id = ObjectId()
  10. @lines = ["original", "lines"]
  11. DocstoreClient.createProject @project_id, (error) =>
  12. throw error if error?
  13. DocstoreClient.createDoc @project_id, @doc_id, @lines, (error) =>
  14. throw error if error?
  15. done()
  16. afterEach (done) ->
  17. DocstoreClient.deleteProject @project_id, done
  18. describe "when the doc exists", ->
  19. it "should get the doc lines", (done) ->
  20. DocstoreClient.getDoc @project_id, @doc_id, (error, res, doc) =>
  21. doc.lines.should.deep.equal @lines
  22. done()
  23. describe "when the doc does not exist", ->
  24. it "should return a 404", (done) ->
  25. missing_doc_id = ObjectId()
  26. DocstoreClient.getDoc @project_id, missing_doc_id, (error, res, doc) ->
  27. res.statusCode.should.equal 404
  28. done()