Created
November 4, 2014 16:31
-
-
Save dwaligora/fb1cbc64b70d84e16666 to your computer and use it in GitHub Desktop.
stub
This file contains hidden or 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
it('should execute MySQL SELECT with orderBy clause', function() { | |
var JobManager = require('../../../app/managers/job').JobManager, | |
tableName = 'dbName', | |
criteria = { name: 'test' }; | |
var jobManager = new JobManager(mySQLMock, tableName); | |
jobManager.find(criteria); | |
expect(mySQLMock.select.calledOnce).to.equal(true); | |
expect(mySQLMock.select.calledTwice).to.equal(false); | |
expect(mySQLMock.select.calledWith('*')).to.equal(true); | |
expect(mySQLMock.select.calledWith('no with this')).to.equal(false); | |
expect(mySQLMock.from.calledOnce).to.equal(true); | |
expect(mySQLMock.from.calledWith(tableName)).to.equal(true); | |
expect(mySQLMock.where.calledOnce).to.equal(true); | |
expect(mySQLMock.where.calledWith(criteria)).to.equal(true); | |
expect(mySQLMock.orderBy.calledOnce).to.equal(false); | |
expect(mySQLMock.limit.calledOnce).to.equal(false); | |
expect(mySQLMock.offset.calledOnce).to.equal(false); | |
}); |
This file contains hidden or 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
'use strict'; | |
var sinon = require('sinon'); | |
/** | |
* mySQLMock object for testing purpose only | |
*/ | |
var mySQLMock = {}; | |
mySQLMock.select = sinon.stub().returnsThis(); | |
mySQLMock.from = sinon.stub().returnsThis(); | |
mySQLMock.where = sinon.stub().returnsThis(); | |
mySQLMock.orderBy = sinon.stub().returnsThis(); | |
mySQLMock.limit = sinon.stub().returnsThis(); | |
mySQLMock.offset = sinon.stub().returnsThis(); | |
mySQLMock.update = sinon.stub().returnsThis(); | |
mySQLMock.insert = sinon.stub().returnsThis(); | |
module.exports = mySQLMock; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment