beforeEach(function () { clock = sinon.useFakeTimers(unix); now = moment(); mmnt = moment(anchor); date = mmnt.toDate(); string = mmnt.format(format); });
beforeEach(function () { // prevent the checker from running automatically checker.destroy(); clock = sinon.useFakeTimers(); schedule = []; _.times(25, function () { schedule.push(_.random(3, 250)); }); });
const init = function () { // Load the application ngMock.module('kibana'); sinon.useFakeTimers(moment(anchor).valueOf()); // Create the scope ngMock.inject(function ($filter) { filter = $filter('moment'); }); };
const init = function () { // Load the application ngMock.module('kibana', function ($provide) { // kibi: added as required after timepicker directive modification $provide.constant('kbnDefaultAppId', ''); }); // Stub out the clock so 'now' doesn't move sinon.useFakeTimers(moment(anchor).valueOf()); // Create the scope ngMock.inject(function ($rootScope, $compile) { // Give us a scope $parentScope = $rootScope; // Add some parameters to it const timefilter = { time : { from: moment().subtract(15, 'minutes'), to: moment(), mode: undefined }, refreshInterval : { value : 0, display : 'Off' } }; $parentScope.timefilter = timefilter; $parentScope.updateInterval = sinon.spy(); $parentScope.updateFilter = sinon.spy(); // Create the element $elem = angular.element( '<kbn-timepicker' + ' from="timefilter.time.from"' + ' to="timefilter.time.to"' + ' mode="timefilter.time.mode"' + ' active-tab="timefilter.timepickerActiveTab"' + ' interval="timefilter.refreshInterval"' + ' on-interval-select="updateInterval(interval)"' + ' on-filter-select="updateFilter(from, to)">' + '</kbn-timepicker>' ); // And compile it $compile($elem)($parentScope); // Fire a digest cycle $elem.scope().$digest(); // Grab the isolate scope so we can test it $scope = $elem.isolateScope(); syncTimeTo = $scope.syncTimeTo = sinon.spy(); // kibi: added to test if syncTimeTo is called }); };
const init = function (expandable) { // Load the application ngMock.module('kibana'); clock = sinon.useFakeTimers(moment(anchor).valueOf()); // Create the scope ngMock.inject(function ($filter, _config_) { filter = $filter('moment'); config = _config_; }); };
var init = function () { // Load the application ngMock.module('kibana'); // Stub out the clock so 'now' doesn't move clock = sinon.useFakeTimers(moment(anchor).valueOf()); // Create the scope ngMock.inject(function ($rootScope, $compile) { // Give us a scope $parentScope = $rootScope; // Add some parameters to it var timefilter = { time : { from: moment().subtract(15, 'minutes'), to: moment(), mode: undefined }, refreshInterval : { value : 0, display : 'Off' } }; $parentScope.timefilter = timefilter; // Create the element $elem = angular.element( '<kbn-timepicker' + ' from="timefilter.time.from"' + ' to="timefilter.time.to"' + ' mode="timefilter.time.mode"' + ' active-tab="timefilter.timepickerActiveTab"' + ' interval="timefilter.refreshInterval">' + '</kbn-timepicker>' ); // And compile it $compile($elem)($parentScope); // Fire a digest cycle $elem.scope().$digest(); // Grab the isolate scope so we can test it $scope = $elem.isolateScope(); }); };
it('emits "resize" based on MS_MAX_RESIZE_DELAY, even if el\'s constantly changing size', function () { const steps = _.random(5, 10); this.slow(steps * 10); // we are going to fake the delay using the fake clock const msStep = Math.floor(ResizeChecker.MS_MAX_RESIZE_DELAY / (steps - 1)); const clock = sinon.useFakeTimers(); _.times(steps, function step(i) { checker.$el.css('height', 100 + i); checker.check(); expect(checker).to.have.property('_isDirty', true); expect(emit).to.have.property('callCount', i > steps ? 1 : 0); clock.tick(msStep); // move the clock forward one step }); });
beforeEach(function () { clock = sinon.useFakeTimers(unix); now = moment(); anchored = moment(anchor); });