Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.