mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
fixed tests
This commit is contained in:
parent
5c73189603
commit
b42df10b5e
14 changed files with 74 additions and 49 deletions
|
@ -6,6 +6,7 @@ define(function (require) {
|
|||
require('directives/config');
|
||||
require('courier/courier');
|
||||
require('config/config');
|
||||
require('notify/notify');
|
||||
|
||||
require('./directives/grid');
|
||||
require('./directives/panel');
|
||||
|
@ -16,6 +17,7 @@ define(function (require) {
|
|||
'ngRoute',
|
||||
'kibana/courier',
|
||||
'kibana/config',
|
||||
'kibana/notify',
|
||||
'kibana/services'
|
||||
]);
|
||||
|
||||
|
@ -96,7 +98,7 @@ define(function (require) {
|
|||
var toggleConfigTemplate = function (name) {
|
||||
var html = configTemplates[name];
|
||||
// Close if already open
|
||||
$scope.configTemplate = ($scope.configTemplate === html) ? null : html;
|
||||
$scope.configTemplate = ($scope.configTemplate === html) ? void 0 : html;
|
||||
return !!$scope.configTemplate;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,7 +4,12 @@ define(function (require) {
|
|||
var settingsHtml = require('text!../partials/settings.html');
|
||||
var timepickerHtml = require('text!partials/timepicker.html');
|
||||
|
||||
var app = require('modules').get('app/discover');
|
||||
require('notify/notify');
|
||||
|
||||
var app = require('modules').get('app/discover', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
require('services/state');
|
||||
require('directives/fixed_scroll');
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
define(function (require) {
|
||||
var module = require('modules').get('discover/saved_searches');
|
||||
var _ = require('lodash');
|
||||
var inherits = require('utils/inherits');
|
||||
|
||||
require('notify/notify');
|
||||
|
||||
var module = require('modules').get('discover/saved_searches', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
module.factory('SavedSearch', function (configFile, courier, Promise, createNotifier, CouriersSearchSource) {
|
||||
var notify = createNotifier({
|
||||
location: 'Saved Search'
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
define(function (require) {
|
||||
|
||||
var module = require('modules').get('discover/saved_searches');
|
||||
var _ = require('lodash');
|
||||
|
||||
require('./saved_search');
|
||||
require('notify/notify');
|
||||
|
||||
var module = require('modules').get('discover/saved_searches', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
module.service('savedSearches', function (courier, configFile, createNotifier, SavedSearch) {
|
||||
var notify = createNotifier({
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var app = require('modules').get('app/visualize');
|
||||
|
||||
require('../factories/vis');
|
||||
require('../services/aggs');
|
||||
require('notify/notify');
|
||||
|
||||
var app = require('modules').get('app/visualize', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
require('routes')
|
||||
.when('/visualize', {
|
||||
|
|
|
@ -4,6 +4,13 @@ define(function (require) {
|
|||
var configFile = require('../../../config');
|
||||
var defaults = require('./defaults');
|
||||
|
||||
require('notify/notify');
|
||||
|
||||
var module = require('modules').get('kibana/config', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
// guid within this window
|
||||
var nextId = (function () {
|
||||
var i = 0;
|
||||
|
@ -12,8 +19,6 @@ define(function (require) {
|
|||
};
|
||||
}());
|
||||
|
||||
var module = require('modules').get('kibana/config');
|
||||
|
||||
// allow the rest of the app to get the configFile easily
|
||||
module.constant('configFile', configFile);
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ define(function (require) {
|
|||
all.forEach(function (req) {
|
||||
req.defer.reject(err);
|
||||
});
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(function (require) {
|
||||
var notify = require('modules').get('notify');
|
||||
var notify = require('modules').get('kibana/notify');
|
||||
|
||||
notify.directive('kbnNotifications', function () {
|
||||
return {
|
||||
|
|
|
@ -68,6 +68,8 @@ define(function (require) {
|
|||
function formatStack(err) {
|
||||
if (!err) return null;
|
||||
|
||||
if (err.stack) return err.stack;
|
||||
|
||||
var isError = (err instanceof Error);
|
||||
var stack = createStackTrace({ e: isError ? err : void 0 });
|
||||
var msg = isError ? err.message : err;
|
||||
|
|
|
@ -3,7 +3,7 @@ define(function (require) {
|
|||
var nextTick = require('utils/next_tick');
|
||||
var $ = require('jquery');
|
||||
var modules = require('modules');
|
||||
var module = modules.get('notify');
|
||||
var module = modules.get('kibana/notify');
|
||||
var errors = require('./errors');
|
||||
var NotifyManager = require('./manager');
|
||||
var manager = new NotifyManager();
|
||||
|
|
|
@ -42,7 +42,9 @@ define(function (require) {
|
|||
$scope.$on('$routeUpdate', updateAppData);
|
||||
|
||||
// this is the only way to handle uncaught route.resolve errors
|
||||
$scope.$on('$routeChangeError', notify.fatal);
|
||||
$scope.$on('$routeChangeError', function (event, next, prev, err) {
|
||||
notify.fatal(err);
|
||||
});
|
||||
|
||||
$scope.$on('application.load', function () {
|
||||
courier.start();
|
||||
|
|
|
@ -2,7 +2,12 @@ define(function (require) {
|
|||
var _ = require('lodash');
|
||||
var $ = require('jquery');
|
||||
|
||||
var module = require('modules').get('kibana/setup');
|
||||
require('notify/notify');
|
||||
|
||||
var module = require('modules').get('kibana/setup', [
|
||||
'kibana/notify',
|
||||
'kibana/courier'
|
||||
]);
|
||||
|
||||
module.service('setup', function (Promise, createNotifier, es, config, configFile) {
|
||||
var notify = createNotifier({
|
||||
|
@ -16,6 +21,7 @@ define(function (require) {
|
|||
function tmplError(err, tmpl) {
|
||||
var err2 = new Error(_.template(tmpl, { configFile: configFile }));
|
||||
err2.origError = err;
|
||||
if (err.stack) err2.stack = err.stack;
|
||||
return err2;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,20 +13,32 @@ define(function (require) {
|
|||
|
||||
describe('Dashboard app', function () {
|
||||
var $scope,
|
||||
location;
|
||||
location,
|
||||
currentDash;
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function (done) {
|
||||
module('app/dashboard');
|
||||
|
||||
// Create the scope
|
||||
inject(function ($rootScope, $controller, $location) {
|
||||
$scope = $rootScope.$new();
|
||||
var dashCtrl = $controller('dashboard', {
|
||||
$scope: $scope
|
||||
});
|
||||
|
||||
location = $location;
|
||||
|
||||
inject(function (savedDashboards, $rootScope, $controller, $location) {
|
||||
savedDashboards.get()
|
||||
.then(function (dash) {
|
||||
currentDash = dash;
|
||||
$scope = $rootScope.$new();
|
||||
var dashCtrl = $controller('dashboard', {
|
||||
$scope: $scope,
|
||||
$route: {
|
||||
current: {
|
||||
locals: {
|
||||
dash: dash
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
location = $location;
|
||||
done();
|
||||
}, done);
|
||||
$rootScope.$apply();
|
||||
// $scope is now available in tests
|
||||
});
|
||||
|
||||
|
@ -36,11 +48,6 @@ define(function (require) {
|
|||
$scope.$destroy();
|
||||
});
|
||||
|
||||
it('should attach $routeParams to scope', function (done) {
|
||||
expect($scope.routeParams).to.be.a(Object);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should have called init and attached some properties', function (done) {
|
||||
expect($scope.gridControl).to.be.a(Object);
|
||||
expect($scope.input.search).to.be('');
|
||||
|
@ -74,26 +81,8 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('loading', function () {
|
||||
beforeEach(function () {
|
||||
$scope.gridControl = {
|
||||
clearGrid: function () {},
|
||||
unserializeGrid: function () {},
|
||||
};
|
||||
_.each($scope.gridControl, function (value, key) {
|
||||
sinon.spy($scope.gridControl, key);
|
||||
});
|
||||
});
|
||||
|
||||
it('should attach the schema to the dashboard object', function (done) {
|
||||
$scope.load({foo: 'bar'});
|
||||
expect($scope.dashboard.foo).to.be('bar');
|
||||
done();
|
||||
});
|
||||
|
||||
it('should clear the grid before loading a new one', function (done) {
|
||||
$scope.load({foo: 'bar'});
|
||||
expect($scope.gridControl.clearGrid.called).to.be(true);
|
||||
expect($scope.gridControl.unserializeGrid.called).to.be(true);
|
||||
it('should attach the dash to the $scope', function (done) {
|
||||
expect($scope.dash).to.be(currentDash);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ define(function (require) {
|
|||
var obj = orig.apply(sinon, arguments);
|
||||
|
||||
// after each test this list is cleared
|
||||
toRestore.push(obj);
|
||||
if (obj.restore) toRestore.push(obj);
|
||||
|
||||
if (typeof modify === 'function') modify(obj);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue