-
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.
[Tests] Wrote some simple tests around the loading indicator and time…
…picker directives
- Loading branch information
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
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 @@ | ||
import ngMock from 'ngMock'; | ||
import expect from 'expect.js'; | ||
import uiModules from 'ui/modules'; | ||
|
||
import '../directives/kbn_loading_indicator'; | ||
|
||
|
||
describe('kbnLoadingIndicator', function () { | ||
let compile; | ||
|
||
beforeEach(() => { | ||
ngMock.module('kibana'); | ||
ngMock.inject(function ($compile, $rootScope) { | ||
compile = function (hasActiveConnections) { | ||
$rootScope.chrome = { | ||
httpActive: (hasActiveConnections ? [1] : []) | ||
}; | ||
const $el = $('<div kbn-loading-indicator><div id="other-content"></div></div>'); | ||
$rootScope.$apply(); | ||
$compile($el)($rootScope); | ||
return $el; | ||
}; | ||
}); | ||
|
||
}); | ||
|
||
it('injects a loading .spinner into the element', function () { | ||
const $el = compile(); | ||
expect($el.find('.spinner')).to.have.length(1); | ||
}); | ||
// Doesn't work... | ||
xit('applies the ng-hide class when there are no connections', function () { | ||
const $el = compile(false); | ||
expect($el.find('.spinner.ng-hide')).to.have.length(1); | ||
}); | ||
it('applies removes ng-hide class when there are connections', function () { | ||
const $el = compile(true); | ||
expect($el.find('.spinner.ng-hide')).to.have.length(0); | ||
}); | ||
|
||
it('doesn\'t modify the contents of what the elment already has', function () { | ||
const $el = compile(); | ||
expect($el.find('#other-content')).to.have.length(1); | ||
}); | ||
|
||
}); |
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
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,22 @@ | ||
import ngMock from 'ngMock'; | ||
import expect from 'expect.js'; | ||
import uiModules from 'ui/modules'; | ||
|
||
describe('kbnGlobalTimepicker', function () { | ||
let compile; | ||
beforeEach(() => { | ||
ngMock.module('kibana'); | ||
ngMock.inject(($compile, $rootScope) => { | ||
compile = () => { | ||
const $el = $('<kbn-global-timepicker></kbn-global-timepicker>'); | ||
$rootScope.$apply(); | ||
$compile($el)($rootScope); | ||
return $el; | ||
} | ||
}); | ||
}); | ||
it('injects the timepicker into the DOM', () => { | ||
const $el = compile(); | ||
expect($el.find('ul.navbar-timepicker')).to.have.length(1); | ||
}); | ||
}); |