Skip to content

Commit

Permalink
refactor(tests): Controller and Module tests renamed and updated
Browse files Browse the repository at this point in the history
  • Loading branch information
pilsy committed Jul 28, 2014
1 parent cb4a07e commit ae22a7e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var expect = require( 'chai' ).expect
, async = require( 'async' )
, sinon = require( 'sinon' )
, underscore = require( 'underscore' )
, path = require( 'path' )
, util = require( 'util' )
, injector = require( 'injector' )
, models = [ { name: 'Testing' }, { name: 'Testing' } ];

Expand Down Expand Up @@ -178,16 +175,22 @@ describe( 'Controller', function () {
});

var res = fakeResponse( function( code, result ) {
expect( code ).to.equal( 400 );

expect( result ).to.be.an( 'object' );
expect( code ).to.equal( 500 );
expect( result ).to.have.property( 'statusCode' ).and.to.eql( 400 );
expect( result ).to.have.property( 'message' ).and.to.eql( 'Invalid data provided to Model.create({})' );

expect( spy.called ).to.eql( true );
expect( ctrl.action ).to.equal( 'postAction' );

expect( result ).to.have.property( 'error' );
expect( result.error ).to.contain( 'Invalid data' );
spy.restore();

done();
});

var spy = sinon.spy( TestController.prototype, 'postAction' );

this.timeout( 10000 );
ctrl = TestController.callback( 'newInstance' )( req, res );
});
Expand Down Expand Up @@ -650,16 +653,18 @@ describe( 'Controller', function () {
});

var res = fakeResponse( function( code, result ) {
expect( code ).to.equal( 500 );
expect( code ).to.equal( 400 );
expect( result ).to.be.an( 'object' );
expect( spy.called ).to.eql( true );
expect( ctrl.action ).to.equal( 'postAction' );

expect( result ).to.have.property( 'error' );
expect( result.error ).to.contain( 'Invalid data' );
spy.restore();

done();
});

var spy = sinon.spy( TestController.prototype, 'postAction' );

this.timeout( 10000 );
ctrl = TestController.callback( 'newInstance' )( req, res );
});
Expand Down
File renamed without changes.

0 comments on commit ae22a7e

Please sign in to comment.