diff --git a/src/ui/public/chrome/__tests__/kbn_loading_indicator.js b/src/ui/public/chrome/__tests__/kbn_loading_indicator.js
new file mode 100644
index 0000000000000..44c3ef31a9418
--- /dev/null
+++ b/src/ui/public/chrome/__tests__/kbn_loading_indicator.js
@@ -0,0 +1,47 @@
+import ngMock from 'ngMock';
+import expect from 'expect.js';
+import uiModules from 'ui/modules';
+import $ from 'jquery';
+
+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 = $('
');
+ $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);
+ });
+
+});
diff --git a/src/ui/public/chrome/directives/kbn_loading_indicator.js b/src/ui/public/chrome/directives/kbn_loading_indicator.js
index 2f954529ba75d..63b32dfb788bf 100644
--- a/src/ui/public/chrome/directives/kbn_loading_indicator.js
+++ b/src/ui/public/chrome/directives/kbn_loading_indicator.js
@@ -1,16 +1,17 @@
import UiModules from 'ui/modules';
+import angular from 'angular';
const spinnerTemplate = '';
UiModules
.get('ui/kibana')
-.directive('kbnLoadingIndicator', function($rootScope, $compile) {
+.directive('kbnLoadingIndicator', function ($compile) {
return {
restrict: 'AC',
- link: function(scope, $el) {
+ link: function (scope, $el) {
const $loadingEl = angular.element(spinnerTemplate);
$el.append($loadingEl);
$compile($loadingEl)(scope);
}
- }
+ };
});
diff --git a/src/ui/public/timepicker/__tests__/toggle.js b/src/ui/public/timepicker/__tests__/toggle.js
new file mode 100644
index 0000000000000..54d3f134db34c
--- /dev/null
+++ b/src/ui/public/timepicker/__tests__/toggle.js
@@ -0,0 +1,23 @@
+import expect from 'expect.js';
+import ngMock from 'ngMock';
+import uiModules from 'ui/modules';
+import $ from 'jquery';
+
+describe('kbnGlobalTimepicker', function () {
+ let compile;
+ beforeEach(() => {
+ ngMock.module('kibana');
+ ngMock.inject(($compile, $rootScope) => {
+ compile = () => {
+ const $el = $('');
+ $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);
+ });
+});
diff --git a/src/ui/public/timepicker/toggle.js b/src/ui/public/timepicker/toggle.js
index c3d5583058e79..c2a10da89712b 100644
--- a/src/ui/public/timepicker/toggle.js
+++ b/src/ui/public/timepicker/toggle.js
@@ -6,7 +6,7 @@ import toggleHtml from './toggle.html';
UiModules
.get('kibana')
-.directive('kbnGlobalTimepicker', function(timefilter, globalState) {
+.directive('kbnGlobalTimepicker', (timefilter, globalState) => {
const listenForUpdates = once($scope => {
$scope.$listen(timefilter, 'update', (newVal, oldVal) => {
globalState.time = clone(timefilter.time);
@@ -17,7 +17,7 @@ UiModules
return {
template: toggleHtml,
- link: function($scope, $el, attrs) {
+ link: ($scope, $el, attrs) => {
listenForUpdates($scope);
$scope.timefilter = timefilter;