mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Get rid of auto-release-sinon in favour of built-in sinon.sandbox functionality. (#12099)
This commit is contained in:
parent
42c1a0b4fc
commit
4bc4c58d8c
75 changed files with 176 additions and 287 deletions
|
@ -205,7 +205,6 @@
|
|||
"@elastic/eslint-config-kibana": "0.5.0",
|
||||
"@elastic/eslint-plugin-kibana-custom": "1.0.3",
|
||||
"angular-mocks": "1.4.7",
|
||||
"auto-release-sinon": "1.0.3",
|
||||
"babel-eslint": "6.1.2",
|
||||
"chai": "3.5.0",
|
||||
"chance": "1.0.6",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import cluster from 'cluster';
|
||||
import { sample } from 'lodash';
|
||||
|
||||
|
@ -7,9 +7,10 @@ import ClusterManager from '../cluster_manager';
|
|||
import Worker from '../worker';
|
||||
|
||||
describe('CLI cluster manager', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
function setup() {
|
||||
sinon.stub(cluster, 'fork', function () {
|
||||
beforeEach(function () {
|
||||
sandbox.stub(cluster, 'fork', function () {
|
||||
return {
|
||||
process: {
|
||||
kill: sinon.stub(),
|
||||
|
@ -20,13 +21,14 @@ describe('CLI cluster manager', function () {
|
|||
send: sinon.stub()
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
const manager = new ClusterManager({});
|
||||
return manager;
|
||||
}
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('has two workers', function () {
|
||||
const manager = setup();
|
||||
const manager = new ClusterManager({});
|
||||
|
||||
expect(manager.workers).to.have.length(2);
|
||||
for (const worker of manager.workers) expect(worker).to.be.a(Worker);
|
||||
|
@ -36,7 +38,7 @@ describe('CLI cluster manager', function () {
|
|||
});
|
||||
|
||||
it('delivers broadcast messages to other workers', function () {
|
||||
const manager = setup();
|
||||
const manager = new ClusterManager({});
|
||||
|
||||
for (const worker of manager.workers) {
|
||||
Worker.prototype.start.call(worker);// bypass the debounced start method
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import cluster from 'cluster';
|
||||
import { findIndex } from 'lodash';
|
||||
|
||||
|
@ -21,24 +21,22 @@ function assertListenerRemoved(emitter, event) {
|
|||
}
|
||||
|
||||
function setup(opts = {}) {
|
||||
sinon.stub(cluster, 'fork', function () {
|
||||
return new MockClusterFork();
|
||||
});
|
||||
|
||||
const worker = new Worker(opts);
|
||||
workersToShutdown.push(worker);
|
||||
return worker;
|
||||
}
|
||||
|
||||
describe('CLI cluster manager', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
beforeEach(function () {
|
||||
sandbox.stub(cluster, 'fork', () => new MockClusterFork());
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
for (const worker of workersToShutdown) {
|
||||
if (worker.shutdown.restore) {
|
||||
// if the shutdown method was stubbed, restore it first
|
||||
worker.shutdown.restore();
|
||||
}
|
||||
sandbox.restore();
|
||||
|
||||
for (const worker of workersToShutdown) {
|
||||
await worker.shutdown();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'ui/render_directive';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import Promise from 'bluebird';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import noDigestPromise from 'test_utils/no_digest_promises';
|
||||
import mockUiState from 'fixtures/mock_ui_state';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import 'ui/private';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import angular from 'angular';
|
||||
import ngMock from 'ng_mock';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import $ from 'jquery';
|
||||
import 'ui/private';
|
||||
|
@ -104,21 +104,19 @@ describe('discover field chooser directives', function () {
|
|||
};
|
||||
|
||||
describe('Index list', function () {
|
||||
it('should be in alphabetical order', function (done) {
|
||||
it('should be in alphabetical order', function () {
|
||||
$elem.find('.ui-select-toggle').click();
|
||||
expect($elem.find('[role=option]').text().replace(/\W+/g, '')).to.be('abc');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Field listing', function () {
|
||||
it('should have Selected Fields, Fields and Popular Fields sections', function (done) {
|
||||
it('should have Selected Fields, Fields and Popular Fields sections', function () {
|
||||
const headers = $elem.find('.sidebar-list-header');
|
||||
expect(headers.length).to.be(3);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should have 2 popular fields, 1 unpopular field and no selected fields', function (done) {
|
||||
it('should have 2 popular fields, 1 unpopular field and no selected fields', function () {
|
||||
const section = getSections($elem);
|
||||
const popular = find('popular');
|
||||
const unpopular = find('unpopular');
|
||||
|
@ -132,7 +130,6 @@ describe('discover field chooser directives', function () {
|
|||
expect(unpopular).to.contain('extension');
|
||||
expect(unpopular).to.contain('machine.os');
|
||||
expect(unpopular).to.not.contain('ssl');
|
||||
done();
|
||||
|
||||
function find(popularity) {
|
||||
return section[popularity]
|
||||
|
@ -143,14 +140,13 @@ describe('discover field chooser directives', function () {
|
|||
});
|
||||
|
||||
|
||||
it('should show the popular fields header if there are popular fields', function (done) {
|
||||
it('should show the popular fields header if there are popular fields', function () {
|
||||
const section = getSections($elem);
|
||||
expect(section.popular.hasClass('ng-hide')).to.be(false);
|
||||
expect(section.popular.find('li:not(.sidebar-list-header)').length).to.be.above(0);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should not show the popular fields if there are not any', function (done) {
|
||||
it('should not show the popular fields if there are not any', function () {
|
||||
|
||||
// Re-init
|
||||
destroy();
|
||||
|
@ -169,10 +165,9 @@ describe('discover field chooser directives', function () {
|
|||
$scope.$digest();
|
||||
expect(section.popular.hasClass('ng-hide')).to.be(true);
|
||||
expect(section.popular.find('li:not(.sidebar-list-header)').length).to.be(0);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should move the field into selected when it is added to the columns array', function (done) {
|
||||
it('should move the field into selected when it is added to the columns array', function () {
|
||||
const section = getSections($elem);
|
||||
$scope.columns.push('bytes');
|
||||
$scope.$digest();
|
||||
|
@ -186,8 +181,6 @@ describe('discover field chooser directives', function () {
|
|||
expect(section.unpopular.text()).to.not.contain('ip\n');
|
||||
|
||||
expect(section.popular.text()).to.contain('ssl');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import $ from 'jquery';
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { AggResponseTabifyProvider } from 'ui/agg_response/tabify/tabify';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
export default function (Private, Promise) {
|
||||
const indexPatterns = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
const getIndexPatternStub = sinon.stub();
|
||||
getIndexPatternStub.returns(Promise.resolve(indexPatterns));
|
||||
const getIndexPatternStub = sinon.stub()
|
||||
.returns(Promise.resolve(indexPatterns));
|
||||
|
||||
const courier = {
|
||||
indexPatterns: { get: getIndexPatternStub },
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
function MockState(defaults) {
|
||||
this.on = _.noop;
|
||||
|
@ -9,9 +9,4 @@ function MockState(defaults) {
|
|||
_.assign(this, defaults);
|
||||
}
|
||||
|
||||
MockState.prototype.resetStub = function () {
|
||||
this.save = sinon.stub();
|
||||
return this;
|
||||
};
|
||||
|
||||
export default MockState;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import searchResponse from 'fixtures/search_response';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
|
||||
function MockMap(container, chartData, params) {
|
||||
this.container = container;
|
||||
this.chartData = chartData;
|
||||
this.params = params;
|
||||
|
||||
// stub required methods
|
||||
this.addStubs();
|
||||
}
|
||||
|
||||
MockMap.prototype.addStubs = function () {
|
||||
this.addTitle = sinon.stub();
|
||||
this.addFitControl = sinon.stub();
|
||||
this.addBoundingControl = sinon.stub();
|
||||
this.destroy = sinon.stub();
|
||||
};
|
||||
|
||||
export default MockMap;
|
|
@ -1,6 +1,6 @@
|
|||
import { values } from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import pluginInit from '../plugin_init';
|
||||
|
||||
describe('Plugin init', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { IndexPatternsMapperProvider } from 'ui/index_patterns/_mapper';
|
||||
import stubbedLogstashFields from 'fixtures/logstash_fields';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
export function stubMapper(Private, mockLogstashFields = Private(stubbedLogstashFields)) {
|
||||
const stubbedMapper = Private(IndexPatternsMapperProvider);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import angular from 'angular';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import '../kbn_accessible_click';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import fixtures from 'fixtures/fake_hierarchical_data';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
|
@ -14,18 +14,22 @@ let indexPattern;
|
|||
let buildHierarchicalData;
|
||||
|
||||
describe('buildHierarchicalData', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (Private, $injector) {
|
||||
// stub the error method before requiring vis causes Notifier#error to be bound
|
||||
Notifier = $injector.get('Notifier');
|
||||
sinon.stub(Notifier.prototype, 'error');
|
||||
sandbox.stub(Notifier.prototype, 'error');
|
||||
|
||||
Vis = Private(VisProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
buildHierarchicalData = Private(BuildHierarchicalDataProvider);
|
||||
}));
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('metric only', function () {
|
||||
let vis;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import moment from 'moment';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { PointSeriesOrderedDateAxisProvider } from 'ui/agg_response/point_series/_ordered_date_axis';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { TabbedAggResponseWriterProvider } from 'ui/agg_response/tabify/_response_writer';
|
||||
|
|
|
@ -4,7 +4,7 @@ import moment from 'moment';
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import fixtures from 'fixtures/fake_hierarchical_data';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { AggResponseTabifyProvider } from 'ui/agg_response/tabify/tabify';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import 'ui/private';
|
||||
import { AggTypesAggParamsProvider } from 'ui/agg_types/agg_params';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { AggTypesParamTypesBaseProvider } from 'ui/agg_types/param_types/base';
|
||||
import { AggTypesParamTypesFieldProvider } from 'ui/agg_types/param_types/field';
|
||||
import { AggTypesParamTypesOptionedProvider } from 'ui/agg_types/param_types/optioned';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import $ from 'jquery';
|
||||
import expect from 'expect.js';
|
||||
import { stub } from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
import { initChromeXsrfApi } from '../xsrf';
|
||||
|
@ -9,6 +9,12 @@ import { version } from '../../../../../../package.json';
|
|||
const xsrfHeader = 'kbn-version';
|
||||
|
||||
describe('chrome xsrf apis', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('#getXsrfToken()', function () {
|
||||
it('exposes the token', function () {
|
||||
const chrome = {};
|
||||
|
@ -19,7 +25,7 @@ describe('chrome xsrf apis', function () {
|
|||
|
||||
describe('jQuery support', function () {
|
||||
it('adds a global jQuery prefilter', function () {
|
||||
stub($, 'ajaxPrefilter');
|
||||
sandbox.stub($, 'ajaxPrefilter');
|
||||
initChromeXsrfApi({}, { version });
|
||||
expect($.ajaxPrefilter.callCount).to.be(1);
|
||||
});
|
||||
|
@ -28,13 +34,13 @@ describe('chrome xsrf apis', function () {
|
|||
let prefilter;
|
||||
|
||||
beforeEach(function () {
|
||||
stub($, 'ajaxPrefilter');
|
||||
sandbox.stub($, 'ajaxPrefilter');
|
||||
initChromeXsrfApi({}, { version });
|
||||
prefilter = $.ajaxPrefilter.args[0][0];
|
||||
});
|
||||
|
||||
it(`sets the ${xsrfHeader} header`, function () {
|
||||
const setHeader = stub();
|
||||
const setHeader = sinon.stub();
|
||||
prefilter({}, {}, { setRequestHeader: setHeader });
|
||||
|
||||
expect(setHeader.callCount).to.be(1);
|
||||
|
@ -45,7 +51,7 @@ describe('chrome xsrf apis', function () {
|
|||
});
|
||||
|
||||
it('can be canceled by setting the kbnXsrfToken option', function () {
|
||||
const setHeader = stub();
|
||||
const setHeader = sinon.stub();
|
||||
prefilter({ kbnXsrfToken: false }, {}, { setRequestHeader: setHeader });
|
||||
expect(setHeader.callCount).to.be(0);
|
||||
});
|
||||
|
@ -57,7 +63,7 @@ describe('chrome xsrf apis', function () {
|
|||
let $httpBackend;
|
||||
|
||||
beforeEach(function () {
|
||||
stub($, 'ajaxPrefilter');
|
||||
sandbox.stub($, 'ajaxPrefilter');
|
||||
const chrome = {};
|
||||
initChromeXsrfApi(chrome, { version });
|
||||
ngMock.module(chrome.$setupXsrfRequestInterceptor);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { RequestQueueProvider } from '../_request_queue';
|
||||
import { SearchStrategyProvider } from '../fetch/strategy/search';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import BluebirdPromise from 'bluebird';
|
||||
|
||||
import { SavedObjectProvider } from '../saved_object/saved_object';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { RequestQueueProvider } from '../../_request_queue';
|
||||
import { DocSourceProvider } from '../doc_source';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { RequestQueueProvider } from '../../_request_queue';
|
||||
import { SearchSourceProvider } from '../search_source';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import IndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import searchResp from 'fixtures/search_response';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import { times } from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import HitSortFnProv from 'plugins/kibana/discover/_hit_sort_fn';
|
||||
import NoDigestPromises from 'test_utils/no_digest_promises';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import ngMock from 'ng_mock';
|
|||
import $ from 'jquery';
|
||||
import 'ui/directives/confirm_click';
|
||||
import 'plugins/kibana/discover/index';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
let $window;
|
||||
|
||||
|
@ -59,16 +59,14 @@ describe('confirmClick directive', function () {
|
|||
events = $._data($elem[0], 'events');
|
||||
});
|
||||
|
||||
it('should get a click handler', function (done) {
|
||||
it('should get a click handler', function () {
|
||||
expect(events).to.be.a(Object);
|
||||
expect(events.click).to.be.a(Array);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should unbind click handlers when the scope is destroyed', function (done) {
|
||||
it('should unbind click handlers when the scope is destroyed', function () {
|
||||
$scope.$destroy();
|
||||
expect(events.click).to.be(undefined);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -78,16 +76,14 @@ describe('confirmClick directive', function () {
|
|||
describe('confirmed', function () {
|
||||
beforeEach(() => init(true));
|
||||
|
||||
it('should trigger window.confirm when clicked', function (done) {
|
||||
it('should trigger window.confirm when clicked', function () {
|
||||
$elem.click();
|
||||
expect($window.confirm.called).to.be(true);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should run the click function when positively confirmed', function (done) {
|
||||
it('should run the click function when positively confirmed', function () {
|
||||
$elem.click();
|
||||
expect($scope.runThis.called).to.be(true);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -95,10 +91,9 @@ describe('confirmClick directive', function () {
|
|||
describe('not confirmed', function () {
|
||||
beforeEach(() => init(false));
|
||||
|
||||
it('should not run the click function when canceled', function (done) {
|
||||
it('should not run the click function when canceled', function () {
|
||||
$elem.click();
|
||||
expect($scope.runThis.called).to.be(false);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -3,9 +3,10 @@ import expect from 'expect.js';
|
|||
import ngMock from 'ng_mock';
|
||||
import 'ui/fixed_scroll';
|
||||
import $ from 'jquery';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('FixedScroll directive', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
let compile;
|
||||
let flushPendingTasks;
|
||||
|
@ -54,13 +55,14 @@ describe('FixedScroll directive', function () {
|
|||
$scroller: $parent.find('.fixed-scroll-scroller')
|
||||
};
|
||||
};
|
||||
|
||||
}));
|
||||
|
||||
afterEach(function () {
|
||||
trash.splice(0).forEach(function ($el) {
|
||||
$el.remove();
|
||||
});
|
||||
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('does nothing when not needed', function () {
|
||||
|
@ -88,8 +90,8 @@ describe('FixedScroll directive', function () {
|
|||
|
||||
describe('scroll event handling / tug of war prevention', function () {
|
||||
it('listens when needed, unlistens when not needed', function () {
|
||||
const on = sinon.spy($.fn, 'on');
|
||||
const off = sinon.spy($.fn, 'off');
|
||||
const on = sandbox.spy($.fn, 'on');
|
||||
const off = sandbox.spy($.fn, 'off');
|
||||
|
||||
const els = compile(1.5);
|
||||
expect(on.callCount).to.be(2);
|
||||
|
@ -123,7 +125,7 @@ describe('FixedScroll directive', function () {
|
|||
let $to;
|
||||
|
||||
beforeEach(function () {
|
||||
spy = sinon.spy($.fn, 'scrollLeft');
|
||||
spy = sandbox.spy($.fn, 'scrollLeft');
|
||||
els = compile(1.5);
|
||||
$from = els[names.from];
|
||||
$to = els[names.to];
|
||||
|
|
|
@ -2,7 +2,7 @@ import angular from 'angular';
|
|||
import moment from 'moment';
|
||||
import expect from 'expect.js';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'plugins/kibana/visualize/index';
|
||||
import 'plugins/kibana/dashboard/index';
|
||||
|
@ -22,9 +22,6 @@ const init = function () {
|
|||
// Load the application
|
||||
ngMock.module('kibana');
|
||||
|
||||
// Stub out the clock so 'now' doesn't move
|
||||
sinon.useFakeTimers(moment(anchor).valueOf());
|
||||
|
||||
// Create the scope
|
||||
ngMock.inject(function ($rootScope, $compile) {
|
||||
|
||||
|
@ -73,40 +70,43 @@ const init = function () {
|
|||
|
||||
|
||||
describe('timepicker directive', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
beforeEach(function () {
|
||||
// Stub out the clock so 'now' doesn't move
|
||||
sandbox.useFakeTimers(moment(anchor).valueOf());
|
||||
|
||||
init();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('tabs', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
it('should contain two tabs', function (done) {
|
||||
it('should contain two tabs', function () {
|
||||
expect($elem.find('.tab-pane').length).to.be(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('refresh interval', function () {
|
||||
beforeEach(function () {
|
||||
init();
|
||||
ngMock.inject(function ($rootScope) {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain a list of options', function (done) {
|
||||
it('should contain a list of options', function () {
|
||||
expect($elem.find('.kbn-refresh-section').length).to.be.greaterThan(0);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should have a $scope.setRefreshInterval() that calls handler', function (done) {
|
||||
it('should have a $scope.setRefreshInterval() that calls handler', function () {
|
||||
$scope.setRefreshInterval({ value : 10000 });
|
||||
sinon.assert.calledOnce($parentScope.updateInterval);
|
||||
expect($parentScope.updateInterval.firstCall.args[0]).to.have.property('value', 10000);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should unpause when setRefreshInterval is called without pause:true', function (done) {
|
||||
it('should unpause when setRefreshInterval is called without pause:true', function () {
|
||||
$scope.setRefreshInterval({ value : 1000, pause: true });
|
||||
expect($parentScope.updateInterval.getCall(0).args[0]).to.have.property('pause', true);
|
||||
|
||||
|
@ -115,32 +115,23 @@ describe('timepicker directive', function () {
|
|||
|
||||
$scope.setRefreshInterval({ value : 1000 });
|
||||
expect($parentScope.updateInterval.getCall(2).args[0]).to.have.property('pause', false);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
|
||||
it('should highlight the current active interval', function (done) {
|
||||
it('should highlight the current active interval', function () {
|
||||
$scope.interval = { value: 300000 };
|
||||
$elem.scope().$digest();
|
||||
expect($elem.find('.refresh-interval-active').length).to.be(1);
|
||||
expect($elem.find('.refresh-interval-active').text().trim()).to.be('5 minutes');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('mode setting', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
it('should be in quick mode by default', function (done) {
|
||||
it('should be in quick mode by default', function () {
|
||||
expect($scope.mode).to.be('quick');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should highlight the right mode', function (done) {
|
||||
it('should highlight the right mode', function () {
|
||||
expect($elem.find('.kbn-timepicker-modes .active').text().trim()).to.be('quick');
|
||||
|
||||
// Each of the 3 modes
|
||||
|
@ -150,59 +141,50 @@ describe('timepicker directive', function () {
|
|||
$scope.$digest();
|
||||
expect($elem.find('.kbn-timepicker-modes .active').text().trim()).to.be(mode);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('quick mode', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
$scope.setMode('quick');
|
||||
$scope.$digest();
|
||||
});
|
||||
|
||||
it('should contain 4 lists of options', function (done) {
|
||||
it('should contain 4 lists of options', function () {
|
||||
expect($elem.find('.kbn-timepicker-section .list-unstyled').length).to.be(4);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should have a $scope.setQuick() that calls handler', function (done) {
|
||||
it('should have a $scope.setQuick() that calls handler', function () {
|
||||
$scope.setQuick('now', 'now');
|
||||
sinon.assert.calledOnce($parentScope.updateFilter);
|
||||
expect($parentScope.updateFilter.firstCall.args[0]).to.be('now');
|
||||
expect($parentScope.updateFilter.firstCall.args[1]).to.be('now');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('relative mode', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
$scope.setMode('relative');
|
||||
$scope.$digest();
|
||||
});
|
||||
|
||||
it('has a preview of the "from" input', function (done) {
|
||||
it('has a preview of the "from" input', function () {
|
||||
const preview = $elem.find('.kbn-timepicker-section span[ng-show="relative.from.preview"]');
|
||||
expect(preview.text()).to.be(moment().subtract(15, 'minutes').format($scope.format));
|
||||
done();
|
||||
});
|
||||
|
||||
it('has a disabled "to" field that contains "Now"', function (done) {
|
||||
it('has a disabled "to" field that contains "Now"', function () {
|
||||
expect($elem.find('.kbn-timepicker-section span[ng-show="relative.to.preview"]').text()).to.be('Now');
|
||||
done();
|
||||
});
|
||||
|
||||
it('has a submit handler', function (done) {
|
||||
it('has a submit handler', function () {
|
||||
const form = $elem.find('form[ng-submit="applyRelative()"]');
|
||||
expect(form.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('disables the submit button if the form is invalid', function (done) {
|
||||
it('disables the submit button if the form is invalid', function () {
|
||||
let button;
|
||||
button = $elem.find('button[disabled]');
|
||||
expect(button.length).to.be(0);
|
||||
|
@ -214,10 +196,9 @@ describe('timepicker directive', function () {
|
|||
|
||||
button = $elem.find('button[disabled]');
|
||||
expect(button.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('has a dropdown bound to relative.from.unit that contains all of the intervals', function (done) {
|
||||
it('has a dropdown bound to relative.from.unit that contains all of the intervals', function () {
|
||||
const select = $elem.find('.kbn-timepicker-section select[ng-model="relative.from.unit"]');
|
||||
expect(select.length).to.be(1);
|
||||
expect(select.find('option').length).to.be(14);
|
||||
|
@ -226,10 +207,9 @@ describe('timepicker directive', function () {
|
|||
_.each($scope.relativeOptions, function (unit, i) {
|
||||
expect(select.find('option')[i].text).to.be(unit.text);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('has a checkbox that is checked when rounding is enabled', function (done) {
|
||||
it('has a checkbox that is checked when rounding is enabled', function () {
|
||||
const checkbox = $elem.find('.kbn-timepicker-section input[ng-model="relative.from.round"]');
|
||||
expect(checkbox.length).to.be(1);
|
||||
|
||||
|
@ -240,11 +220,9 @@ describe('timepicker directive', function () {
|
|||
$scope.relative.from.round = true;
|
||||
$scope.$digest();
|
||||
expect(checkbox.prop('checked')).to.be(true);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('rounds the preview down to the unit when rounding is enabled', function (done) {
|
||||
it('rounds the preview down to the unit when rounding is enabled', function () {
|
||||
// Enable rounding
|
||||
$scope.relative.from.round = true;
|
||||
$scope.relative.from.count = 0;
|
||||
|
@ -257,11 +235,9 @@ describe('timepicker directive', function () {
|
|||
// The preview should match the start of the unit eg, the start of the minute
|
||||
expect($scope.relative.from.preview).to.be(moment().startOf(longUnit).format($scope.format));
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('does not round the preview down to the unit when rounding is disable', function (done) {
|
||||
it('does not round the preview down to the unit when rounding is disable', function () {
|
||||
// Disable rounding
|
||||
$scope.relative.from.round = false;
|
||||
$scope.relative.from.count = 1;
|
||||
|
@ -283,11 +259,9 @@ describe('timepicker directive', function () {
|
|||
// The preview should match the start of the unit eg, the start of the minute
|
||||
expect($scope.relative.from.preview).to.be(moment()[fn](1, unit).format($scope.format));
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('has a $scope.applyRelative() that sets from and to based on relative.round, relative.count and relative.unit', function (done) {
|
||||
it('has a $scope.applyRelative() that sets from and to based on relative.round, relative.count and relative.unit', function () {
|
||||
// Disable rounding
|
||||
$scope.relative.from.round = false;
|
||||
$scope.relative.from.count = 1;
|
||||
|
@ -312,11 +286,9 @@ describe('timepicker directive', function () {
|
|||
$scope.relative.from.unit = 'd';
|
||||
$scope.applyRelative();
|
||||
expect($parentScope.updateFilter.getCall(3).args[0]).to.be('now-7d/d');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('updates the input fields when the scope variables are changed', function (done) {
|
||||
it('updates the input fields when the scope variables are changed', function () {
|
||||
const input = $elem.find('.kbn-timepicker-section input[ng-model="relative.from.count"]');
|
||||
const select = $elem.find('.kbn-timepicker-section select[ng-model="relative.from.unit"]');
|
||||
|
||||
|
@ -332,11 +304,7 @@ describe('timepicker directive', function () {
|
|||
|
||||
expect(select.val().split(':')[1]).to.be(shortUnit);
|
||||
});
|
||||
|
||||
done();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('absolute mode', function () {
|
||||
|
@ -344,7 +312,6 @@ describe('timepicker directive', function () {
|
|||
let inputs;
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
$scope.setMode('absolute');
|
||||
$scope.$digest();
|
||||
|
||||
|
@ -354,22 +321,19 @@ describe('timepicker directive', function () {
|
|||
fromCalendar: $elem.find('.kbn-timepicker-section div[ng-model="pickFromDate"] '),
|
||||
toCalendar: $elem.find('.kbn-timepicker-section div[ng-model="pickToDate"] '),
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
it('should have input boxes for absolute.from and absolute.to', function (done) {
|
||||
it('should have input boxes for absolute.from and absolute.to', function () {
|
||||
expect(inputs.fromInput.length).to.be(1);
|
||||
expect(inputs.toInput.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should have tables that contain calendars bound to absolute.from and absolute.to', function (done) {
|
||||
it('should have tables that contain calendars bound to absolute.from and absolute.to', function () {
|
||||
expect(inputs.fromCalendar.length).to.be(1);
|
||||
expect(inputs.toCalendar.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should present a timeframe of 15 minutes ago to now if scope.from and scope.to are not set', function (done) {
|
||||
it('should present a timeframe of 15 minutes ago to now if scope.from and scope.to are not set', function () {
|
||||
delete $scope.from;
|
||||
delete $scope.to;
|
||||
$scope.setMode('absolute');
|
||||
|
@ -377,10 +341,9 @@ describe('timepicker directive', function () {
|
|||
|
||||
expect($scope.absolute.from.valueOf()).to.be(moment().subtract(15, 'minutes').valueOf());
|
||||
expect($scope.absolute.to.valueOf()).to.be(moment().valueOf());
|
||||
done();
|
||||
});
|
||||
|
||||
it('should update its own variables if timefilter time is updated', function (done) {
|
||||
it('should update its own variables if timefilter time is updated', function () {
|
||||
$scope.setMode('absolute');
|
||||
$scope.$digest();
|
||||
|
||||
|
@ -393,10 +356,9 @@ describe('timepicker directive', function () {
|
|||
|
||||
expect($scope.absolute.from.valueOf()).to.be(startDate.valueOf());
|
||||
expect($scope.absolute.to.valueOf()).to.be(endDate.valueOf());
|
||||
done();
|
||||
});
|
||||
|
||||
it('should disable the "Go" button if from > to', function (done) {
|
||||
it('should disable the "Go" button if from > to', function () {
|
||||
$scope.absolute.from = moment('2012-02-01');
|
||||
$scope.absolute.to = moment('2012-02-11');
|
||||
$scope.$digest();
|
||||
|
@ -406,10 +368,9 @@ describe('timepicker directive', function () {
|
|||
$scope.absolute.to = moment('2012-02-11');
|
||||
$scope.$digest();
|
||||
expect($elem.find('[data-test-subj="timepickerGoButton"]').attr('disabled')).to.be('disabled');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should only copy its input to scope.from and scope.to when scope.applyAbsolute() is called', function (done) {
|
||||
it('should only copy its input to scope.from and scope.to when scope.applyAbsolute() is called', function () {
|
||||
$scope.from = 'now-30m';
|
||||
$scope.to = 'now';
|
||||
|
||||
|
@ -423,22 +384,18 @@ describe('timepicker directive', function () {
|
|||
expect($parentScope.updateFilter.firstCall.args[1]).to.eql(moment('2012-02-11'));
|
||||
|
||||
$scope.$digest();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should set from/to to start/end of day if set from datepicker', function (done) {
|
||||
it('should set from/to to start/end of day if set from datepicker', function () {
|
||||
$scope.pickFromDate(new Date('2012-02-01 12:00'));
|
||||
$scope.pickToDate(new Date('2012-02-11 12:00'));
|
||||
$scope.applyAbsolute();
|
||||
|
||||
expect($parentScope.updateFilter.firstCall.args[0].valueOf()).to.be(moment('2012-02-01 00:00:00.000').valueOf());
|
||||
expect($parentScope.updateFilter.firstCall.args[1].valueOf()).to.be(moment('2012-02-11 23:59:59.999').valueOf());
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should allow setting hour/minute/second after setting from datepicker', function (done) {
|
||||
it('should allow setting hour/minute/second after setting from datepicker', function () {
|
||||
$scope.pickFromDate(new Date('2012-02-01 12:00'));
|
||||
$scope.pickToDate(new Date('2012-02-11 12:00'));
|
||||
$scope.applyAbsolute();
|
||||
|
@ -452,12 +409,10 @@ describe('timepicker directive', function () {
|
|||
|
||||
expect($parentScope.updateFilter.secondCall.args[0].valueOf()).to.be(moment('2012-02-01 01:23:45').valueOf());
|
||||
expect($parentScope.updateFilter.secondCall.args[1].valueOf()).to.be(moment('2012-02-11 12:34:56').valueOf());
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
describe('datepicker timezone issue', function () {
|
||||
it('should ignore the timezone from the datepicker because it does not respect dateFormat:tz advanced setting', function (done) {
|
||||
it('should ignore the timezone from the datepicker because it does not respect dateFormat:tz advanced setting', function () {
|
||||
moment.tz.setDefault('UTC');
|
||||
|
||||
$scope.pickFromDate(new Date('2012-02-01 12:00-05:00'));
|
||||
|
@ -469,8 +424,6 @@ describe('timepicker directive', function () {
|
|||
|
||||
expect(formattedFrom).to.be('2012-02-01 00:00:00.000');
|
||||
expect(formattedTo).to.be('2012-02-11 23:59:59.999');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import angular from 'angular';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import getFakeRow from 'fixtures/fake_row';
|
||||
|
@ -50,13 +50,12 @@ describe('Doc Table', function () {
|
|||
//
|
||||
const columnTests = function (elemType, parentElem) {
|
||||
|
||||
it('should create a time column if the timefield is defined', function (done) {
|
||||
it('should create a time column if the timefield is defined', function () {
|
||||
const childElems = parentElem.find(elemType);
|
||||
expect(childElems.length).to.be(2);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should be able to add and remove columns', function (done) {
|
||||
it('should be able to add and remove columns', function () {
|
||||
let childElems;
|
||||
// Should include a column for toggling and the time column by default
|
||||
$parentScope.columns = ['bytes'];
|
||||
|
@ -76,16 +75,14 @@ describe('Doc Table', function () {
|
|||
childElems = parentElem.find(elemType);
|
||||
expect(childElems.length).to.be(3);
|
||||
expect($(childElems[2]).text()).to.contain('request_body');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should create only the toggle column if there is no timeField', function (done) {
|
||||
it('should create only the toggle column if there is no timeField', function () {
|
||||
delete parentElem.scope().indexPattern.timeFieldName;
|
||||
parentElem.scope().$digest();
|
||||
|
||||
const childElems = parentElem.find(elemType);
|
||||
expect(childElems.length).to.be(1);
|
||||
done();
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { DocTitleProvider } from 'ui/doc_title';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'ui/private';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
import { FilterBarQueryFilterProvider } from 'ui/filter_bar/query_filter';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { FilterBarLibGenerateMappingChainProvider } from 'ui/filter_bar/lib/generate_mapping_chain';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import MockState from 'fixtures/mock_state';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import moment from 'moment';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'ui/filters/moment';
|
||||
|
@ -11,7 +11,6 @@ const anchor = '2014-01-01T06:06:06.666';
|
|||
const init = function () {
|
||||
// Load the application
|
||||
ngMock.module('kibana');
|
||||
sinon.useFakeTimers(moment(anchor).valueOf());
|
||||
|
||||
// Create the scope
|
||||
ngMock.inject(function ($filter) {
|
||||
|
@ -21,11 +20,18 @@ const init = function () {
|
|||
|
||||
|
||||
describe('moment formatting filter', function () {
|
||||
const sandbox = sinon.sandbox.create();
|
||||
|
||||
beforeEach(function () {
|
||||
sandbox.useFakeTimers(moment(anchor).valueOf());
|
||||
|
||||
init();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('should have a moment filter', function () {
|
||||
expect(filter).to.not.be(null);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import Promise from 'bluebird';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { pluck } from 'lodash';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import moment from 'moment';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { IndexPatternProvider } from '../_index_pattern';
|
||||
import { IndexPatternsProvider } from '../index_patterns';
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'ui/listen';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('pattern checker', function () {
|
||||
let $httpBackend;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import noDigestPromises from 'test_utils/no_digest_promises';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('Promise service', function () {
|
||||
let Promise;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import $ from 'jquery';
|
||||
import { delay } from 'bluebird';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import ngMock from 'ng_mock';
|
||||
import { EventsProvider } from 'ui/events';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import _ from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import RouteManager from 'ui/routes/route_manager';
|
||||
import expect from 'expect.js';
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash';
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { WorkQueue } from 'ui/routes/work_queue';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import 'ui/promises';
|
||||
|
||||
describe('work queue', function () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import 'ui/state_management/app_state';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { parse as parseUrl } from 'url';
|
||||
|
||||
import { StateProvider } from 'ui/state_management/state';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { StateProvider } from 'ui/state_management/state';
|
||||
import { unhashUrl } from 'ui/state_management/state_hashing';
|
||||
|
|
|
@ -3,14 +3,11 @@ import chrome from 'ui/chrome';
|
|||
|
||||
import sinon from 'sinon';
|
||||
import { Notifier } from 'ui/notify/notifier';
|
||||
import { setupAutoRelease } from 'auto-release-sinon';
|
||||
|
||||
import './test_harness.less';
|
||||
import 'ng_mock';
|
||||
import { setupTestSharding } from './test_sharding';
|
||||
|
||||
// Setup auto releasing stubs and spys
|
||||
setupAutoRelease(sinon, window.afterEach);
|
||||
setupTestSharding();
|
||||
|
||||
// allows test_harness.less to have higher priority selectors
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { TimefilterLibDiffIntervalProvider } from 'ui/timefilter/lib/diff_interval';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { TimefilterLibDiffTimeProvider } from 'ui/timefilter/lib/diff_time';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import faker from 'faker';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { SimpleEmitter } from 'ui/utils/simple_emitter';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('SimpleEmitter class', function () {
|
||||
let emitter;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { VisProvider } from 'ui/vis';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import ngMock from 'ng_mock';
|
||||
import { VisAggConfigProvider } from 'ui/vis/agg_config';
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import expect from 'expect.js';
|
||||
import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { positionTooltip } from '../position_tooltip';
|
||||
|
||||
describe('Tooltip Positioning', function () {
|
||||
|
||||
const sandbox = sinon.sandbox.create();
|
||||
const positions = ['north', 'south', 'east', 'west'];
|
||||
const bounds = ['top', 'left', 'bottom', 'right', 'area'];
|
||||
let $window;
|
||||
|
@ -51,6 +51,7 @@ describe('Tooltip Positioning', function () {
|
|||
$window.remove();
|
||||
$window = $chart = $tooltip = $sizer = null;
|
||||
positionTooltip.removeClone();
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
function makeEvent(xPercent, yPercent) {
|
||||
|
@ -67,8 +68,8 @@ describe('Tooltip Positioning', function () {
|
|||
|
||||
describe('getTtSize()', function () {
|
||||
it('should measure the outer-size of the tooltip using an un-obstructed clone', function () {
|
||||
const w = sinon.spy($.fn, 'outerWidth');
|
||||
const h = sinon.spy($.fn, 'outerHeight');
|
||||
const w = sandbox.spy($.fn, 'outerWidth');
|
||||
const h = sandbox.spy($.fn, 'outerHeight');
|
||||
|
||||
positionTooltip.getTtSize($tooltip.html(), $sizer);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _ from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import { AggResponseTabifyTableProvider } from 'ui/agg_response/tabify/_table';
|
||||
import { AggResponseIndexProvider } from 'ui/agg_response/index';
|
||||
import { VislibVisTypeBuildChartDataProvider } from 'ui/vislib_vis_type/build_chart_data';
|
||||
|
|
|
@ -2,7 +2,7 @@ import _ from 'lodash';
|
|||
import $ from 'jquery';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
import VislibProvider from 'ui/vislib';
|
||||
import { VislibVisProvider } from 'ui/vislib/vis';
|
||||
import { VisRenderbotProvider } from 'ui/vis/renderbot';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import _ from 'lodash';
|
||||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
import sinon from 'auto-release-sinon';
|
||||
import sinon from 'sinon';
|
||||
|
||||
describe('$scope.$watchMulti', function () {
|
||||
|
||||
|
|
|
@ -1,41 +1 @@
|
|||
const sinon = require('sinon');
|
||||
const autoRelease = require('auto-release-sinon');
|
||||
|
||||
require('../src/optimize/babel/register');
|
||||
|
||||
// hook into the global afterEach variable to allow autoReleaseSinon to register
|
||||
// an afterEach handler before mocha has exposed itself to the test files.
|
||||
//
|
||||
// This works by telling autoReleaseSinon to use a fake "afterEach" function.
|
||||
// Rather than actually record an afterEach handler the function tracks all of
|
||||
// the calls it received and queues them up in queuedAfterEachArgs.
|
||||
//
|
||||
// The global "afterEach" variable is also tracked, and once it is assigned by mocha
|
||||
// the variable global is reconfigured to point directly to the new value (from mocha)
|
||||
// and all of the queued invocations are executed.
|
||||
const queuedAfterEachArgs = [];
|
||||
Object.defineProperty(global, 'afterEach', {
|
||||
configurable: true,
|
||||
get() { return undefined; },
|
||||
set(afterEach) {
|
||||
Object.defineProperty(global, 'afterEach', {
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: afterEach
|
||||
});
|
||||
|
||||
queuedAfterEachArgs.forEach(function (args) {
|
||||
afterEach.apply(null, args);
|
||||
});
|
||||
|
||||
return global.afterEach;
|
||||
}
|
||||
});
|
||||
|
||||
autoRelease.setupAutoRelease(sinon, function () {
|
||||
if (!global.afterEach) {
|
||||
queuedAfterEachArgs.push(Array.prototype.slice.call(arguments));
|
||||
} else {
|
||||
global.afterEach.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue