Skip to content

Instantly share code, notes, and snippets.

@ihordiachenko
Created March 9, 2018 15:42
Show Gist options
  • Save ihordiachenko/1a6232ce8b2808bd8c0a469b793e4496 to your computer and use it in GitHub Desktop.
Save ihordiachenko/1a6232ce8b2808bd8c0a469b793e4496 to your computer and use it in GitHub Desktop.
describe('init', function() {
beforeEach(function() {
ctrl.statistics = undefined;
sinon.stub(ctrl.statisticsService, 'getRangeVerbose');
sinon.stub(ctrl, 'initRangePicker');
sinon.stub(ctrl, 'watchFilters');
sinon.stub(ctrl, 'pick');
sinon.stub(ctrl, 'getFilters');
});
describe('when custom date isn’t set', function() {
it('initiliazes and doesn’t call getRangeVerbose()', function() {
ctrl.getFilters.returns({isCustom: false});
ctrl.init();
expect(ctrl.statistics).to.be.not.empty;
expect(ctrl.statisticsService.getRangeVerbose).to.have
.not.been.called;
expect(ctrl.initRangePicker).to.have.been.called;
expect(ctrl.watchFilters).to.have.been.called;
expect(ctrl.pick).to.have.been.called;
});
});
describe('when custom date set', function() {
it('initiliazes and calls getRangeVerbose()', function() {
ctrl.getFilters.returns({isCustom: true});
ctrl.init();
expect(ctrl.statistics).to.be.not.empty;
expect(ctrl.statisticsService.getRangeVerbose).to.have.been
.called;
expect(ctrl.initRangePicker).to.have.been.called;
expect(ctrl.watchFilters).to.have.been.called;
expect(ctrl.pick).to.have.been.called;
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment