Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Created September 20, 2012 23:54
Show Gist options
  • Save fivetanley/3759016 to your computer and use it in GitHub Desktop.
Save fivetanley/3759016 to your computer and use it in GitHub Desktop.
support file for mocha tests
// requirejs global - hm....
define( function( require ) {
var support = require( 'support' )
// chai js loaded with sinon-chai and chai-jquery
, expect = support.expect
// sinon.js stub function. I also have spy and mock functions available
// on the support object
, stub = support.stub
, REPL = require( 'models/repl' )
// Nope, I was wrong. "describe" and "it" functions are in the global scope...
describe( 'REPL', function() {
beforeEach( function() {
this.repl = new REPL()
})
describe( 'evaluating input', function() {
it( 'returns the evaluated input', function() {
expect( this.repl.$eval( '2+2' ) ).to.equal( 4 )
})
})
})
});
define( function( require ) {
var sinon = require( 'sinon' )
, sinonChai = require( 'sinon_chai' )
, jquery = require( 'jquery' )
, chai = require( 'chai' )
, chaiJquery = require( 'chai_jquery' )
, relief = require( 'relief' )
, expect
chai.use( sinonChai )
chai.use( chaiJquery )
expect = chai.expect
return {
sinon: sinon
, $: jquery
, expect: expect
, stub: sinon.stub
, spy: sinon.spy
, mock: sinon.mock
, relief: relief
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment