Created
November 13, 2019 20:38
-
-
Save nkhil/7d7c89776b3eb297708a3f7dc3e2f456 to your computer and use it in GitHub Desktop.
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
// file: controller.spec.js | |
const proxyquire = require('proxyquire'); | |
const sinon = require('sinon'); | |
const chai = require('chai'); | |
const { expect } = chai; | |
describe('calculateTotal', function(done) { | |
it('calculates the total and updates the database', function() { | |
const databaseUpdaterSpy = sinon.spy(); | |
const stub = { | |
'../model/databaseUpdater': databaseUpdaterSpy, | |
}; | |
const calculateTotal = proxyquire('../controller', stub); | |
calculateTotal([2, 3, 5]); | |
expect(databaseUpdaterSpy.getCall(0).calledWith(sinon.match({ body: 10 }))).to.be.true; | |
done(); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment