testbase.coffee 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ###
  2. Copyright (c) 2014 Ramesh Nair (hiddentao.com)
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. ###
  22. sinon = require('sinon')
  23. chai = require("chai")
  24. assert = chai.assert
  25. expect = chai.expect
  26. should = chai.should()
  27. ###
  28. Assert that two items are the same.
  29. @param actual
  30. @param expected
  31. @param {String} [message] failure message
  32. ###
  33. assert.same = (actual, expected, message) ->
  34. assert.deepEqual(actual, expected, message)
  35. testCreator = ->
  36. test =
  37. mocker: null
  38. beforeEach: ->
  39. test.mocker = sinon.sandbox.create()
  40. afterEach: ->
  41. test.mocker.restore()
  42. test
  43. module?.exports =
  44. _: require('underscore')
  45. testCreator: testCreator
  46. assert: assert
  47. expect: expect
  48. should: should