Created
October 4, 2012 20:57
-
-
Save stim371/3836403 to your computer and use it in GitHub Desktop.
example model test for question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'Statement', -> | |
createStatement = (callback)-> | |
domtest (window)-> | |
Statement = window.require 'models/statement' | |
model = new Statement() | |
callback(model) | |
it 'can be initialized', (done)-> | |
createStatement (model)-> | |
should.exist(model) | |
# expect(model).to.exist | |
done() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## require or set up global helpers for tests - these will be automagically availabe in each test ## | |
chai = require('chai') | |
sinon = require('sinon') | |
global.expect = chai.expect | |
global.assert = chai.assert | |
global.should = chai.should() | |
global.sinon = sinon | |
# use jsdom to setup our test environment for dom-based tests | |
jsdom = require('jsdom'); | |
global.domtest = (html, callback)-> | |
if html instanceof Function | |
callback = html | |
html = '<html><body></body></html>' | |
jsdom.env( | |
html, | |
[ | |
'../public/js/jquery.js' | |
'../public/js/vendor.js' | |
'../public/js/app.js' | |
], | |
(errors, window)-> | |
console.log errors if errors | |
callback(window) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment