added tests for error handler constructor

This commit is contained in:
Shelby Sturgis 2014-09-01 15:47:43 +03:00
parent abc8ac4d44
commit 59140ec386
2 changed files with 43 additions and 0 deletions

View file

@ -100,6 +100,7 @@
'specs/vislib/index',
'specs/vislib/vis',
'specs/vislib/handler',
'specs/vislib/_error_handler',
'specs/utils/diff_time_picker_vals',
'specs/factories/events',
'specs/index_patterns/_flatten_search_response',

View file

@ -0,0 +1,42 @@
define(function (require) {
var angular = require('angular');
angular.module('ErrorHandlerFactory', ['kibana']);
describe('VisLib ErrorHandler Test Suite', function () {
var ErrorHandler;
var errorHandler;
beforeEach(function () {
module('ErrorHandlerFactory');
});
beforeEach(function () {
inject(function (Private) {
ErrorHandler = Private(require('components/vislib/modules/_error_handler'));
errorHandler = new ErrorHandler();
});
});
describe('validateWidthandHeight Method', function () {
it('should throw an error when width and/or height is 0', function () {
expect(function () {
errorHandler.validateWidthandHeight(0, 200);
}).to.throwError();
expect(function () {
errorHandler.validateWidthandHeight(200, 0);
}).to.throwError();
});
it('should throw an error when width and/or height is NaN', function () {
expect(function () {
errorHandler.validateWidthandHeight(null, 200);
}).to.throwError();
expect(function () {
errorHandler.validateWidthandHeight(200, null);
}).to.throwError();
});
});
});
});