forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] angularjs controller initialization tests. (elastic#25382)
* [ML] Confirm Modal Controller Test. * [ML] Message Bar Controller test. * [ML] Data Visualizer Controller test. * [ML] Detector Filter Modal Controller test. * [ML] Detector Modal Controller test. * [ML] Save Status Modal Controller test. * [ML] Multi Metric Create Job Controller test. * [ML] Population Create Job Controller test. * [ML] Recognize Create Job Controller test. * [ML] Single Metric Create Job Controller test. * [ML] Index Or Search Controller test. * [ML] Job Type Controller test. * [ML] Angular Bootstrap Patch Dropdown Controller test. * [ML] Settings Controller test. * [ML] Calenders List Controller test. * [ML] New Event Modal Controller test. * [ML] New Event Modal Controller test. * [ML] Create Calendar Controller test. * [ML] Time Series Explorer Controller test. * [ML] Fixes typo, clearer test name. * [ML] Fixes tests by restoring stubs.
- Loading branch information
Showing
20 changed files
with
648 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/ml/public/components/confirm_modal/__tests__/confirm_modal_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/ml/public/components/messagebar/__tests__/messagebar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/ml/public/datavisualizer/__tests__/datavisualizer_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...jobs/new_job/advanced/detector_filter_modal/__tests__/detector_filter_modal_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
...ins/ml/public/jobs/new_job/advanced/detector_modal/__tests__/detector_modal_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
.../public/jobs/new_job/advanced/save_status_modal/__tests__/save_status_modal_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
.../ml/public/jobs/new_job/simple/multi_metric/create_job/__tests__/create_job_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
...ns/ml/public/jobs/new_job/simple/population/create_job/__tests__/create_job_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
...ins/ml/public/jobs/new_job/simple/recognize/create_job/__tests__/create_job_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
...ml/public/jobs/new_job/simple/single_metric/create_job/__tests__/create_job_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.