Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should fire the update and fetch events', function () {
var emitSpy = sinon.spy(queryFilter, 'emit');
appState.filters = filters;
// set up the watchers
$rootScope.$digest();
queryFilter.invertFilter(filters[1]);
// trigger the digest loop to fire the watchers
$rootScope.$digest();
expect(emitSpy.callCount).to.be(2);
expect(emitSpy.firstCall.args[0]).to.be('update');
expect(emitSpy.secondCall.args[0]).to.be('fetch');
});
});
it('should fire the update and fetch events', function () {
var emitSpy = sinon.spy(queryFilter, 'emit');
appState.filters = filters;
$rootScope.$digest();
queryFilter.toggleFilter(filters[1]);
$rootScope.$digest();
expect(emitSpy.callCount).to.be(2);
expect(emitSpy.firstCall.args[0]).to.be('update');
expect(emitSpy.secondCall.args[0]).to.be('fetch');
});
it('should fire the update and fetch events', function () {
var emitSpy = sinon.spy(queryFilter, 'emit');
appState.filters = filters;
$rootScope.$digest();
queryFilter.removeFilter(filters[0]);
$rootScope.$digest();
expect(emitSpy.callCount).to.be(2);
expect(emitSpy.firstCall.args[0]).to.be('update');
expect(emitSpy.secondCall.args[0]).to.be('fetch');
});
it('should only fire the update event', function () {
var emitSpy = sinon.spy(queryFilter, 'emit');
var filter = appState.filters[1];
$rootScope.$digest();
queryFilter.pinFilter(filter);
$rootScope.$digest();
expect(emitSpy.callCount).to.be(1);
expect(emitSpy.firstCall.args[0]).to.be('update');
});
});
it('always emits the handlers that were initially registered', function () {
var destructive = sinon.spy(function () {
emitter.removeAllListeners();
expect(emitter.listenerCount()).to.be(0);
});
var stub = sinon.stub();
emitter.on('run', destructive).on('run', stub).emit('run');
expect(destructive).to.have.property('callCount', 1);
expect(stub).to.have.property('callCount', 1);
});
it('clears the timeout', function () {
var spy = sinon.spy(window, 'clearTimeout');
checker.destroy();
expect(spy).to.have.property('callCount', 1);
});
});
it('should measure the outer-size of the tooltip using an un-obstructed clone', function () {
var w = sinon.spy($.fn, 'outerWidth');
var h = sinon.spy($.fn, 'outerHeight');
posTT.getTtSize($tooltip.html(), $sizer);
[w, h].forEach(function (spy) {
expect(spy).to.have.property('callCount', 1);
var matchHtml = w.thisValues.filter(function ($t) {
return !$t.is($tooltip) && $t.html() === $tooltip.html();
});
expect(matchHtml).to.have.length(1);
});
});
});
it('relies on agg.buckets for the interval', function () {
var args = _.cloneDeep(baseArgs);
var spy = sinon.spy(args.chart.aspects.x.agg.buckets, 'getInterval');
orderedDateAxis(args.vis, args.chart);
expect(spy).to.have.property('callCount', 1);
});
beforeEach(ngMock.inject(function (Private) {
ResizeChecker = Private(require('ui/vislib/lib/resize_checker'));
EventEmitter = Private(require('ui/events'));
reflowWatcher = Private(require('ui/reflow_watcher'));
reflowSpies.on = sinon.spy(reflowWatcher, 'on');
reflowSpies.off = sinon.spy(reflowWatcher, 'off');
var $el = $(document.createElement('div'))
.appendTo('body')
.css('visibility', 'hidden')
.get(0);
checker = new ResizeChecker($el);
}));
return function ($delegate) {
sinon.spy($delegate, prop);
return $delegate;
};
}