Test:
describe('Event Widget', () => {
it('should throw error when no option are passed in', () => {
sinon.stub(ErrorHandler, 'renderErrorTemplate');
ErrorHandler('divId');
ErrorHandler.renderErrorTemplate.should.have.been.called;
});
});
Code:
const ErrorHandler = require('../../helpers/error_handler');
(() => {
let events = (divId, options, env) => {
if (isUndefined(options)) {
ErrorHandler.renderErrorTemplate(divId, 'Options cannot be undefined.');
}
...
});
Expected result: Test should pass, method should be mocked. Actual method should never be called, instead use mock.
Actual Result: It calls the real method and tries to render a marco template. As a result it explodes on "unknown characters such as <
via TheWebs
No comments:
Post a Comment