From 5a0ba4e13335fdb2b969d29ca990f29470744ca8 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 16:44:04 +0100 Subject: [PATCH 01/21] [ML] Confirm Modal Controller Test. --- .../__tests__/confirm_modal_controller.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js diff --git a/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js b/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js new file mode 100644 index 0000000000000..371e783b90d3e --- /dev/null +++ b/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () { }, dismiss: function () { } }; + +describe('ML - Confirm Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Confirm Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlConfirmModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: {} + }); + + expect(scope.okLabel).to.be('OK'); + done(); + }); + }); +}); From 0b9afa1b9e08db393bdbe2b7ffa3c4d165fe5830 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 16:55:01 +0100 Subject: [PATCH 02/21] [ML] Message Bar Controller test. --- .../messagebar/__tests__/messagebar.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 x-pack/plugins/ml/public/components/messagebar/__tests__/messagebar.js diff --git a/x-pack/plugins/ml/public/components/messagebar/__tests__/messagebar.js b/x-pack/plugins/ml/public/components/messagebar/__tests__/messagebar.js new file mode 100644 index 0000000000000..b39cc57757eb9 --- /dev/null +++ b/x-pack/plugins/ml/public/components/messagebar/__tests__/messagebar.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Message Bar Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Message Bar Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlMessageBarController', { $scope: scope }); + + expect(scope.messages).to.eql([]); + done(); + }); + }); +}); From d798544341728207b5de22198fbdf310613d7346 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 17:08:33 +0100 Subject: [PATCH 03/21] [ML] Data Visualizer Controller test. --- .../__tests__/datavisualizer_controller.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js diff --git a/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js b/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js new file mode 100644 index 0000000000000..ef5f7d9571ec8 --- /dev/null +++ b/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import * as indexUtils from 'plugins/ml/util/index_utils'; + +describe('ML - Data Visualizer View Fields Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Data Visualizer View Fields Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlDataVisualizerViewFields', { $scope: scope }); + + expect(scope.metricCards).to.eql([]); + done(); + }); + }); +}); From a32b329889631794f94757f701e3c54b79ddd043 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 17:19:35 +0100 Subject: [PATCH 04/21] [ML] Detector Filter Modal Controller test. --- .../detector_filter_modal_controller.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js new file mode 100644 index 0000000000000..47231c43c3746 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () { }, dismiss: function () { } }; + +describe('ML - Detector Filter Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Detector Filter Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlDetectorFilterModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: { detector: {} } + }); + + expect(scope.title).to.eql('Add new filter'); + done(); + }); + }); +}); From 23010a7eadd53c5b6d1f3ccd7d0d44fc93b05ebd Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 17:25:48 +0100 Subject: [PATCH 05/21] [ML] Detector Modal Controller test. --- .../__tests__/confirm_modal_controller.js | 2 +- .../detector_filter_modal_controller.js | 2 +- .../__tests__/detector_modal_controller.js | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/detector_modal/__tests__/detector_modal_controller.js diff --git a/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js b/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js index 371e783b90d3e..c8cbe26632501 100644 --- a/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js +++ b/x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js @@ -9,7 +9,7 @@ import ngMock from 'ng_mock'; import expect from 'expect.js'; -const mockModalInstance = { close: function () { }, dismiss: function () { } }; +const mockModalInstance = { close: function () {}, dismiss: function () {} }; describe('ML - Confirm Modal Controller', () => { beforeEach(() => { diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js index 47231c43c3746..d617c0b2d2e47 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js @@ -9,7 +9,7 @@ import ngMock from 'ng_mock'; import expect from 'expect.js'; -const mockModalInstance = { close: function () { }, dismiss: function () { } }; +const mockModalInstance = { close: function () {}, dismiss: function () {} }; describe('ML - Detector Filter Modal Controller', () => { beforeEach(() => { diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_modal/__tests__/detector_modal_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_modal/__tests__/detector_modal_controller.js new file mode 100644 index 0000000000000..30226dc304f8c --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/detector_modal/__tests__/detector_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () {}, dismiss: function () {} }; + +describe('ML - Detector Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Detector Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlDetectorModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: {} + }); + + expect(scope.title).to.eql('Add new detector'); + done(); + }); + }); +}); From 73b7b780e33cd99e737e14e31e861f9ee58d9c9a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 17:44:27 +0100 Subject: [PATCH 06/21] [ML] Save Status Modal Controller test. --- .../__tests__/save_status_modal_controller.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/advanced/save_status_modal/__tests__/save_status_modal_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/save_status_modal/__tests__/save_status_modal_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/save_status_modal/__tests__/save_status_modal_controller.js new file mode 100644 index 0000000000000..7d0ec43015b37 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/save_status_modal/__tests__/save_status_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () { }, dismiss: function () { } }; + +describe('ML - Save Status Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Save Status Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlSaveStatusModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: {} + }); + + expect(scope.ui.showTimepicker).to.eql(false); + done(); + }); + }); +}); From abf184c2e958361e445e0b098979b03f8044e53a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 18:02:14 +0100 Subject: [PATCH 07/21] [ML] Multi Metric Create Job Controller test. --- .../__tests__/create_job_controller.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js new file mode 100644 index 0000000000000..5856fe47e55e2 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import * as indexUtils from 'plugins/ml/util/index_utils'; +import * as utils from 'plugins/ml/jobs/new_job/simple/components/utils/create_fields'; + +describe('ML - Multi Metric Wizard - Create Job Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Create Job Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + sinon.stub(utils, 'createFields').callsFake(() => false); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCreateMultiMetricJob', { $scope: scope }); + + expect(typeof scope.ui).to.eql('object'); + done(); + }); + }); +}); From 0165aa263f30a60240cf4012a7a99da84c3dedee Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Wed, 7 Nov 2018 18:18:52 +0100 Subject: [PATCH 08/21] [ML] Population Create Job Controller test. --- .../__tests__/create_job_controller.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js new file mode 100644 index 0000000000000..b13c0d5e79f7f --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import * as indexUtils from 'plugins/ml/util/index_utils'; +import * as utils from 'plugins/ml/jobs/new_job/simple/components/utils/create_fields'; + +describe('ML - Population Wizard - Create Job Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Create Job Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + sinon.stub(utils, 'createFields').callsFake(() => false); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCreatePopulationJob', { $scope: scope }); + + expect(typeof scope.ui).to.eql('object'); + done(); + }); + }); +}); From 67badf3dbd307ed9311552df368913585f448db8 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 10:36:58 +0100 Subject: [PATCH 09/21] [ML] Recognize Create Job Controller test. --- .../__tests__/create_job_controller.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js new file mode 100644 index 0000000000000..37c7545e7421f --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js @@ -0,0 +1,42 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; + +describe('ML - Recognize Wizard - Create Job Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Create Job Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCreateRecognizerJobs', { + $route: { + current: { + params: {} + } + }, + $scope: scope + }); + + expect(scope.ui.formValid).to.eql(true); + done(); + }); + }); +}); From 6bf10ed1a9d13f17b328d829e8c7bcd9d3ca987a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 10:45:41 +0100 Subject: [PATCH 10/21] [ML] Single Metric Create Job Controller test. --- .../__tests__/create_job_controller.js | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js new file mode 100644 index 0000000000000..0118c8c7b6416 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import * as indexUtils from 'plugins/ml/util/index_utils'; + +describe('ML - Single Metric Wizard - Create Job Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Create Job Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCreateSingleMetricJob', { + $route: { + current: { + params: {} + } + }, + $scope: scope + }); + + expect(scope.ui.showJobInput).to.eql(false); + done(); + }); + }); +}); From 937761145f1daf8f2253bfc1930a3e0b43d1e8dc Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 12:23:52 +0100 Subject: [PATCH 11/21] [ML] Index Or Search Controller test. --- .../__tests__/index_or_search_controller.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js new file mode 100644 index 0000000000000..251a231a80e71 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Index Or Search Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Index Or Sesarch Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlNewJobStepIndexOrSearch', { + $route: { + current: { + locals: {} + } + }, + $scope: scope + }); + + expect(scope.indexPatterns).to.eql([]); + done(); + }); + }); +}); From 5a86e75fe5f1654153389c543762e2baef140a2c Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 12:29:42 +0100 Subject: [PATCH 12/21] [ML] Job Type Controller test. --- .../job_type/__tests__/job_type_controller.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js diff --git a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js new file mode 100644 index 0000000000000..ac4ba65b274bc --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; +import sinon from 'sinon'; + +// Import this way to be able to stub/mock functions later on in the tests using sinon. +import * as newJobUtils from 'plugins/ml/jobs/new_job/utils/new_job_utils'; +import * as indexUtils from 'plugins/ml/util/index_utils'; + +describe('ML - Job Type Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Job Type Controller', (done) => { + sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlNewJobStepJobType', { $scope: scope }); + + expect(scope.indexWarningTitle).to.eql('Index pattern undefined is not time based'); + done(); + }); + }); +}); From 75e5a969f87629be09bb318e075d1086464550c8 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 12:40:33 +0100 Subject: [PATCH 13/21] [ML] Angular Bootstrap Patch Dropdown Controller test. --- .../lib/__tests__/angular_bootstrap_patch.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js diff --git a/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js b/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js new file mode 100644 index 0000000000000..d432f376ccb60 --- /dev/null +++ b/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Angular Patch - Dropdown Controller', () => { + beforeEach(() => { + ngMock.module('ui.bootstrap.dropdown'); + }); + + it('Initialize Dropdown Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + + expect(scope.$$watchersCount).to.eql(0); + + $controller('DropdownController', { + $attrs: [], + $scope: scope + }); + + expect(scope.$$watchersCount).to.eql(1); + done(); + }); + }); +}); From 02a8ef7531e20481330b1695e48d32b7f3e21520 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 12:48:17 +0100 Subject: [PATCH 14/21] [ML] Settings Controller test. --- .../settings/__tests__/settings_controller.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 x-pack/plugins/ml/public/settings/__tests__/settings_controller.js diff --git a/x-pack/plugins/ml/public/settings/__tests__/settings_controller.js b/x-pack/plugins/ml/public/settings/__tests__/settings_controller.js new file mode 100644 index 0000000000000..cd5a6b1a921e9 --- /dev/null +++ b/x-pack/plugins/ml/public/settings/__tests__/settings_controller.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Settings Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Settings Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlSettings', { $scope: scope }); + + expect(scope.canCreateFilter).to.eql(false); + done(); + }); + }); +}); From 516d70096af13c7e5c991dca6bbb6c32ddad58c9 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 13:09:53 +0100 Subject: [PATCH 15/21] [ML] Calenders List Controller test. --- .../__tests__/calendars_list_controller.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 x-pack/plugins/ml/public/settings/scheduled_events/calendars_list/__tests__/calendars_list_controller.js diff --git a/x-pack/plugins/ml/public/settings/scheduled_events/calendars_list/__tests__/calendars_list_controller.js b/x-pack/plugins/ml/public/settings/scheduled_events/calendars_list/__tests__/calendars_list_controller.js new file mode 100644 index 0000000000000..9875172b76208 --- /dev/null +++ b/x-pack/plugins/ml/public/settings/scheduled_events/calendars_list/__tests__/calendars_list_controller.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Calendars List Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Calendars List Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCalendarsList', { $scope: scope }); + + expect(scope.permissions.canCreateCalendar).to.eql(false); + done(); + }); + }); +}); From 808d8299f9849595a6498dc176bbfd544755ca6b Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 13:12:21 +0100 Subject: [PATCH 16/21] [ML] New Event Modal Controller test. --- .../import_events_modal_controller.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/settings/scheduled_events/components/import_events_modal/__tests__/import_events_modal_controller.js diff --git a/x-pack/plugins/ml/public/settings/scheduled_events/components/import_events_modal/__tests__/import_events_modal_controller.js b/x-pack/plugins/ml/public/settings/scheduled_events/components/import_events_modal/__tests__/import_events_modal_controller.js new file mode 100644 index 0000000000000..073a3c1db9469 --- /dev/null +++ b/x-pack/plugins/ml/public/settings/scheduled_events/components/import_events_modal/__tests__/import_events_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () { }, dismiss: function () { } }; + +describe('ML - Import Events Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Import Events Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlImportEventsModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: {} + }); + + expect(scope.loadingLock).to.be(false); + done(); + }); + }); +}); From feeb053514ca114751470331293c29413142c1ec Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 13:15:44 +0100 Subject: [PATCH 17/21] [ML] New Event Modal Controller test. --- .../__tests__/new_event_modal_controller.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 x-pack/plugins/ml/public/settings/scheduled_events/components/new_event_modal/__tests__/new_event_modal_controller.js diff --git a/x-pack/plugins/ml/public/settings/scheduled_events/components/new_event_modal/__tests__/new_event_modal_controller.js b/x-pack/plugins/ml/public/settings/scheduled_events/components/new_event_modal/__tests__/new_event_modal_controller.js new file mode 100644 index 0000000000000..312fb31a7101c --- /dev/null +++ b/x-pack/plugins/ml/public/settings/scheduled_events/components/new_event_modal/__tests__/new_event_modal_controller.js @@ -0,0 +1,32 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +const mockModalInstance = { close: function () { }, dismiss: function () { } }; + +describe('ML - New Event Modal Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize New Event Modal Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlNewEventModal', { + $scope: scope, + $modalInstance: mockModalInstance, + params: {} + }); + + expect(scope.event.description).to.be(''); + done(); + }); + }); +}); From 093f37be07f9870a65f53d0da57b6a7db1bb2d51 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 13:21:40 +0100 Subject: [PATCH 18/21] [ML] Create Calendar Controller test. --- .../__tests__/create_calendar_controller.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 x-pack/plugins/ml/public/settings/scheduled_events/new_calendar/__tests__/create_calendar_controller.js diff --git a/x-pack/plugins/ml/public/settings/scheduled_events/new_calendar/__tests__/create_calendar_controller.js b/x-pack/plugins/ml/public/settings/scheduled_events/new_calendar/__tests__/create_calendar_controller.js new file mode 100644 index 0000000000000..8827152b85b56 --- /dev/null +++ b/x-pack/plugins/ml/public/settings/scheduled_events/new_calendar/__tests__/create_calendar_controller.js @@ -0,0 +1,33 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Create Calendar Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Create Calendar Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlCreateCalendar', { + $route: { + current: { + params: {} + } + }, + $scope: scope + }); + + expect(scope.isNewCalendar).to.eql(true); + done(); + }); + }); +}); From 138a02e6100dba9a629552c71e6d57b59eb2545c Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 13:23:44 +0100 Subject: [PATCH 19/21] [ML] Time Series Explorer Controller test. --- .../timeseriesexplorer_controller.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseriesexplorer_controller.js diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseriesexplorer_controller.js b/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseriesexplorer_controller.js new file mode 100644 index 0000000000000..ab8105b9ef8e6 --- /dev/null +++ b/x-pack/plugins/ml/public/timeseriesexplorer/__tests__/timeseriesexplorer_controller.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + + + +import ngMock from 'ng_mock'; +import expect from 'expect.js'; + +describe('ML - Time Series Explorer Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Time Series Explorer Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlTimeSeriesExplorerController', { $scope: scope }); + + expect(scope.timeFieldName).to.eql('timestamp'); + done(); + }); + }); +}); From b375232a338207383ca11195bc7b3109e1701c1a Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 14:13:11 +0100 Subject: [PATCH 20/21] [ML] Fixes typo, clearer test name. --- .../index_or_search/__tests__/index_or_search_controller.js | 2 +- .../plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js index 251a231a80e71..c596567a9e84a 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/index_or_search/__tests__/index_or_search_controller.js @@ -14,7 +14,7 @@ describe('ML - Index Or Search Controller', () => { ngMock.module('kibana'); }); - it('Initialize Index Or Sesarch Controller', (done) => { + it('Initialize Index Or Search Controller', (done) => { ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlNewJobStepIndexOrSearch', { diff --git a/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js b/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js index d432f376ccb60..2a6603f3cc343 100644 --- a/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js +++ b/x-pack/plugins/ml/public/lib/__tests__/angular_bootstrap_patch.js @@ -9,7 +9,7 @@ import ngMock from 'ng_mock'; import expect from 'expect.js'; -describe('ML - Angular Patch - Dropdown Controller', () => { +describe('ML - Angular Bootstrap Patch - Dropdown Controller', () => { beforeEach(() => { ngMock.module('ui.bootstrap.dropdown'); }); From 930924ce3599e29414268ae764eb2073c83f11b2 Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 8 Nov 2018 16:47:54 +0100 Subject: [PATCH 21/21] [ML] Fixes tests by restoring stubs. --- .../__tests__/datavisualizer_controller.js | 6 ++++-- .../new_job/advanced/__tests__/new_job_controller.js | 4 +++- .../create_job/__tests__/create_job_controller.js | 9 ++++++--- .../create_job/__tests__/create_job_controller.js | 9 ++++++--- .../create_job/__tests__/create_job_controller.js | 3 ++- .../create_job/__tests__/create_job_controller.js | 6 ++++-- .../steps/job_type/__tests__/job_type_controller.js | 6 ++++-- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js b/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js index ef5f7d9571ec8..0a12a574f7949 100644 --- a/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js +++ b/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js @@ -20,17 +20,19 @@ describe('ML - Data Visualizer View Fields Controller', () => { }); it('Initialize Data Visualizer View Fields Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); - sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + const stub2 = sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlDataVisualizerViewFields', { $scope: scope }); expect(scope.metricCards).to.eql([]); + stub1.restore(); + stub2.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/advanced/__tests__/new_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/advanced/__tests__/new_job_controller.js index 11224b9b5f96b..8f4f41968ab0f 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/advanced/__tests__/new_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/advanced/__tests__/new_job_controller.js @@ -18,11 +18,12 @@ describe('ML - Advanced Job Wizard - New Job Controller', () => { }); it('Initialize New Job Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); + ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlNewJob', { $scope: scope }); @@ -31,6 +32,7 @@ describe('ML - Advanced Job Wizard - New Job Controller', () => { // all angularjs based dependencies get loaded without error. // This simple scope test is just a final sanity check. expect(scope.ui.pageTitle).to.be('Create a new job'); + stub.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js index 5856fe47e55e2..74031afc7a715 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js @@ -21,18 +21,21 @@ describe('ML - Multi Metric Wizard - Create Job Controller', () => { }); it('Initialize Create Job Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); - sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); - sinon.stub(utils, 'createFields').callsFake(() => false); + const stub2 = sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + const stub3 = sinon.stub(utils, 'createFields').callsFake(() => false); ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlCreateMultiMetricJob', { $scope: scope }); expect(typeof scope.ui).to.eql('object'); + stub1.restore(); + stub2.restore(); + stub3.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js index b13c0d5e79f7f..9cedc38106e9c 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js @@ -21,18 +21,21 @@ describe('ML - Population Wizard - Create Job Controller', () => { }); it('Initialize Create Job Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); - sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); - sinon.stub(utils, 'createFields').callsFake(() => false); + const stub2 = sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + const stub3 = sinon.stub(utils, 'createFields').callsFake(() => false); ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlCreatePopulationJob', { $scope: scope }); expect(typeof scope.ui).to.eql('object'); + stub1.restore(); + stub2.restore(); + stub3.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js index 37c7545e7421f..786d06afbc40e 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js @@ -19,7 +19,7 @@ describe('ML - Recognize Wizard - Create Job Controller', () => { }); it('Initialize Create Job Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} @@ -36,6 +36,7 @@ describe('ML - Recognize Wizard - Create Job Controller', () => { }); expect(scope.ui.formValid).to.eql(true); + stub.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js index 0118c8c7b6416..bc9ba3a250262 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js @@ -20,12 +20,12 @@ describe('ML - Single Metric Wizard - Create Job Controller', () => { }); it('Initialize Create Job Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); - sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + const stub2 = sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlCreateSingleMetricJob', { @@ -38,6 +38,8 @@ describe('ML - Single Metric Wizard - Create Job Controller', () => { }); expect(scope.ui.showJobInput).to.eql(false); + stub1.restore(); + stub2.restore(); done(); }); }); diff --git a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js index ac4ba65b274bc..9786df1976c7c 100644 --- a/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js +++ b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_controller.js @@ -20,17 +20,19 @@ describe('ML - Job Type Controller', () => { }); it('Initialize Job Type Controller', (done) => { - sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ indexPattern: {}, savedSearch: {}, combinedQuery: {} })); - sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); + const stub2 = sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); ngMock.inject(function ($rootScope, $controller) { const scope = $rootScope.$new(); $controller('MlNewJobStepJobType', { $scope: scope }); expect(scope.indexWarningTitle).to.eql('Index pattern undefined is not time based'); + stub1.restore(); + stub2.restore(); done(); }); });