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..c8cbe26632501 --- /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(); + }); + }); +}); 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(); + }); + }); +}); 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..0a12a574f7949 --- /dev/null +++ b/x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_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'; + +describe('ML - Data Visualizer View Fields Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Data Visualizer View Fields Controller', (done) => { + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + 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/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..d617c0b2d2e47 --- /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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +}); 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..74031afc7a715 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/multi_metric/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'; +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) => { + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + 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 new file mode 100644 index 0000000000000..9cedc38106e9c --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/population/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'; +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) => { + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + 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 new file mode 100644 index 0000000000000..786d06afbc40e --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js @@ -0,0 +1,43 @@ +/* + * 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) => { + const stub = 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); + 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 new file mode 100644 index 0000000000000..bc9ba3a250262 --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js @@ -0,0 +1,46 @@ +/* + * 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) => { + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + const stub2 = 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); + stub1.restore(); + stub2.restore(); + done(); + }); + }); +}); 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..c596567a9e84a --- /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 Search Controller', (done) => { + ngMock.inject(function ($rootScope, $controller) { + const scope = $rootScope.$new(); + $controller('MlNewJobStepIndexOrSearch', { + $route: { + current: { + locals: {} + } + }, + $scope: scope + }); + + expect(scope.indexPatterns).to.eql([]); + 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 new file mode 100644 index 0000000000000..9786df1976c7c --- /dev/null +++ b/x-pack/plugins/ml/public/jobs/new_job/wizard/steps/job_type/__tests__/job_type_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'; + +describe('ML - Job Type Controller', () => { + beforeEach(() => { + ngMock.module('kibana'); + }); + + it('Initialize Job Type Controller', (done) => { + const stub1 = sinon.stub(newJobUtils, 'createSearchItems').callsFake(() => ({ + indexPattern: {}, + savedSearch: {}, + combinedQuery: {} + })); + 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(); + }); + }); +}); 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..2a6603f3cc343 --- /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 Bootstrap 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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +}); 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(); + }); + }); +});