Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
});
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();
});
});
});
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();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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();
});
});
Expand Down
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();
});
});
});
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();
});
});
});
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();
});
});
});
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();
});
});
});
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();
});
});
});
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();
});
});
});
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();
});
});
});
Loading