-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/__test__/directive.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,45 @@ | ||
/* | ||
* 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 '@kbn/expect'; | ||
import sinon from 'sinon'; | ||
|
||
// Import this way to be able to stub/mock functions later on in the tests using sinon. | ||
import * as indexUtils from 'plugins/ml/util/index_utils'; | ||
|
||
describe('ML - Recognize job directive', () => { | ||
let $scope; | ||
let $compile; | ||
let $element; | ||
|
||
beforeEach(ngMock.module('kibana')); | ||
beforeEach(() => { | ||
ngMock.inject(function ($injector) { | ||
$compile = $injector.get('$compile'); | ||
const $rootScope = $injector.get('$rootScope'); | ||
$scope = $rootScope.$new(); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
$scope.$destroy(); | ||
}); | ||
|
||
it('Initialize Index or Saved Search selection directive', done => { | ||
sinon.stub(indexUtils, 'timeBasedIndexCheck').callsFake(() => false); | ||
ngMock.inject(function () { | ||
expect(() => { | ||
$element = $compile('<ml-recognize-page />')($scope); | ||
}).to.not.throwError(); | ||
|
||
// directive has scope: false | ||
const scope = $element.isolateScope(); | ||
expect(scope).to.eql(undefined); | ||
done(); | ||
}); | ||
}); | ||
}); |