Skip to content

Instantly share code, notes, and snippets.

@heymichaelp
Last active August 29, 2015 14:03
Show Gist options
  • Save heymichaelp/59011114a48fb7f2900b to your computer and use it in GitHub Desktop.
Save heymichaelp/59011114a48fb7f2900b to your computer and use it in GitHub Desktop.
Query Objects: Testing
var expect = require('chai').expect;
var CreateStudentQuery = require('./createStudentQuery');
describe('CreateStudentQuery', function(){
before(function(done){
this.student = {
first_name: 'John',
last_name: 'Smith',
gender: 'M'
}
var callback = _.bind(function(err, result) {
this.err = err
this.result = result
done()
}, this)
// set the collection being affected as a test table
// or set the DATABASE_URL to a test database instead.
CreateStudentQuery.COLLECTION_NAME = 'students_test'
new CreateStudentQuery(this.student).run(callback)
});
// perform checks to make sure that the returned object is
// has the same values as the original object but also
// has new database values (such as _id in Mongo)
it('returns a new student database object', function(){
expect(this.result.first_name).to.equal(this.student.first_name)
expect(this.results._id).to.not.be.undefined
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment