mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
adding tests for the new error handlers that were put in
This commit is contained in:
parent
fea744a5b1
commit
2f5265d6e0
20 changed files with 450 additions and 26 deletions
|
@ -111,26 +111,26 @@
|
|||
'specs/state_management/app_state',
|
||||
'specs/utils/diff_object',
|
||||
'specs/factories/events',
|
||||
'specs/vislib/color',
|
||||
'specs/vislib/zero_injection',
|
||||
'specs/vislib/labels',
|
||||
'specs/vislib/x_axis',
|
||||
'specs/vislib/y_axis',
|
||||
'specs/vislib/axis_title',
|
||||
'specs/vislib/chart_title',
|
||||
'specs/vislib/layout_types',
|
||||
'specs/vislib/vis_types',
|
||||
'specs/vislib/splits',
|
||||
'specs/vislib/layout',
|
||||
'specs/vislib/_chart',
|
||||
'specs/vislib/column_layout',
|
||||
'specs/vislib/components/color',
|
||||
'specs/vislib/components/zero_injection',
|
||||
'specs/vislib/components/labels',
|
||||
'specs/vislib/lib/x_axis',
|
||||
'specs/vislib/lib/y_axis',
|
||||
'specs/vislib/lib/axis_title',
|
||||
'specs/vislib/lib/chart_title',
|
||||
'specs/vislib/lib/layout_types',
|
||||
'specs/vislib/lib/splits',
|
||||
'specs/vislib/lib/layout',
|
||||
'specs/vislib/lib/tooltip',
|
||||
'specs/vislib/lib/handler',
|
||||
'specs/vislib/lib/_error_handler',
|
||||
'specs/vislib/lib/data',
|
||||
'specs/vislib/lib/column_layout',
|
||||
'specs/vislib/lib/resize_checker',
|
||||
'specs/vislib/visualizations/_chart',
|
||||
'specs/vislib/visualizations/vis_types',
|
||||
'specs/vislib/index',
|
||||
'specs/vislib/vis',
|
||||
'specs/vislib/tooltip',
|
||||
'specs/vislib/handler',
|
||||
'specs/vislib/_error_handler',
|
||||
'specs/vislib/data',
|
||||
'specs/vislib/resize_checker',
|
||||
'specs/utils/diff_time_picker_vals',
|
||||
'specs/factories/events',
|
||||
'specs/index_patterns/_flatten_search_response',
|
||||
|
|
|
@ -12,8 +12,14 @@ define(function (require) {
|
|||
describe('Color (main)', function () {
|
||||
var getColors;
|
||||
var arr = ['good', 'better', 'best', 'never', 'let', 'it', 'rest'];
|
||||
var str = 'test';
|
||||
var error;
|
||||
var arrayOfNumbers = [1, 2, 3, 4, 5];
|
||||
var arrayOfUndefinedValues = [undefined, undefined, undefined];
|
||||
var arrayOfObjects = [{}, {}, {}];
|
||||
var arrayOfBooleans = [true, false, true];
|
||||
var arrayOfNullValues = [null, null, null];
|
||||
var emptyObject = {};
|
||||
var nullValue = null;
|
||||
var notAValue;
|
||||
var color;
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -24,11 +30,66 @@ define(function (require) {
|
|||
inject(function (d3, Private) {
|
||||
seedColors = Private(require('components/vislib/components/color/seed_colors'));
|
||||
getColors = Private(require('components/vislib/components/color/color'));
|
||||
// error = getColors(str);
|
||||
color = getColors(arr);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an array', function () {
|
||||
expect(function () {
|
||||
getColors(200);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors('help');
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(true);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(notAValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(emptyObject);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an error if array is not composed of numbers, strings, or ' +
|
||||
'undefined values', function () {
|
||||
expect(function () {
|
||||
getColors(arrayOfObjects);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(arrayOfBooleans);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(arrayOfNullValues);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should not throw an error if input is an array of strings, numbers, or' +
|
||||
' undefined values', function () {
|
||||
expect(function () {
|
||||
getColors(arr);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(arrayOfNumbers);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
getColors(arrayOfUndefinedValues);
|
||||
}).to.not.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(typeof getColors).to.be('function');
|
||||
});
|
||||
|
@ -40,11 +101,6 @@ define(function (require) {
|
|||
it('should return the first hex color in the seed colors array', function () {
|
||||
expect(color(arr[0])).to.be(seedColors[0]);
|
||||
});
|
||||
|
||||
// it('should throw a TypeError when the input value is not an array', function () {
|
||||
// console.log(error);
|
||||
// expect(error).to.throwException(typeof str + ' should be an array of strings or numbers');
|
||||
// });
|
||||
});
|
||||
|
||||
describe('Seed Colors', function () {
|
||||
|
@ -66,6 +122,12 @@ define(function (require) {
|
|||
var num1 = 45;
|
||||
var num2 = 72;
|
||||
var num3 = 90;
|
||||
var string = 'Welcome';
|
||||
var bool = true;
|
||||
var nullValue = null;
|
||||
var emptyArr = [];
|
||||
var emptyObject = {};
|
||||
var notAValue;
|
||||
var createColorPalette;
|
||||
var colorPalette;
|
||||
|
||||
|
@ -75,11 +137,38 @@ define(function (require) {
|
|||
|
||||
beforeEach(function () {
|
||||
inject(function (d3, Private) {
|
||||
seedColors = Private(require('components/vislib/components/color/seed_colors'));
|
||||
createColorPalette = Private(require('components/vislib/components/color/color_palette'));
|
||||
colorPalette = createColorPalette(num1);
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not a number', function () {
|
||||
expect(function () {
|
||||
createColorPalette(string);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createColorPalette(bool);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createColorPalette(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createColorPalette(emptyArr);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createColorPalette(emptyObject);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createColorPalette(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(typeof createColorPalette).to.be('function');
|
||||
});
|
|
@ -157,6 +157,24 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('Data array', function () {
|
||||
var childrenObject = {
|
||||
children: []
|
||||
};
|
||||
var seriesObject = {
|
||||
series: []
|
||||
};
|
||||
var rowsObject = {
|
||||
rows: []
|
||||
};
|
||||
var columnsObject = {
|
||||
columns: []
|
||||
};
|
||||
var string = 'string';
|
||||
var number = 23;
|
||||
var boolean = false;
|
||||
var emptyArray = [];
|
||||
var nullValue = null;
|
||||
var notAValue;
|
||||
var dataArray;
|
||||
var testSeries;
|
||||
var testRows;
|
||||
|
@ -175,6 +193,56 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if the input is not an object', function () {
|
||||
expect(function () {
|
||||
dataArray(string);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(emptyArray);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an error if property series, rows, or columns is not ' +
|
||||
'present', function () {
|
||||
|
||||
expect(function () {
|
||||
dataArray(childrenObject);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should not throw an error if object has property series, rows, or ' +
|
||||
'columns', function () {
|
||||
|
||||
expect(function () {
|
||||
dataArray(seriesObject);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(rowsObject);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
dataArray(columnsObject);
|
||||
}).to.not.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(typeof dataArray).to.equal('function');
|
||||
});
|
||||
|
@ -214,6 +282,13 @@ define(function (require) {
|
|||
{'label': 'd'},
|
||||
{'label': 'f'}
|
||||
];
|
||||
var string = 'string';
|
||||
var number = 24;
|
||||
var boolean = false;
|
||||
var nullValue = null;
|
||||
var emptyObject = {};
|
||||
var emptyArray = [];
|
||||
var notAValue;
|
||||
var uniq;
|
||||
var testArr;
|
||||
|
||||
|
@ -229,6 +304,38 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an array', function () {
|
||||
expect(function () {
|
||||
uniqLabels(string);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqLabels(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqLabels(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqLabels(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqLabels(emptyObject);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqLabels(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should not throw an error if the input is an array', function () {
|
||||
expect(function () {
|
||||
uniqLabels(emptyArray);
|
||||
}).to.not.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(typeof uniqLabels).to.be('function');
|
||||
});
|
||||
|
@ -244,6 +351,19 @@ define(function (require) {
|
|||
});
|
||||
|
||||
describe('Get series', function () {
|
||||
var string = 'string';
|
||||
var number = 24;
|
||||
var boolean = false;
|
||||
var nullValue = null;
|
||||
var rowsObject = {
|
||||
rows: []
|
||||
};
|
||||
var columnsObject = {
|
||||
columns: []
|
||||
};
|
||||
var emptyObject = {};
|
||||
var emptyArray = [];
|
||||
var notAValue;
|
||||
var getSeries;
|
||||
var columnsLabels;
|
||||
var rowsLabels;
|
||||
|
@ -264,6 +384,48 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an object', function () {
|
||||
expect(function () {
|
||||
getSeries(string);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(emptyArray);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an if property rows or columns is not set on the object', function () {
|
||||
expect(function () {
|
||||
getSeries(emptyObject);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should not throw an error if rows or columns set on object', function () {
|
||||
expect(function () {
|
||||
getSeries(rowsObject);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
getSeries(columnsObject);
|
||||
}).to.not.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(typeof getSeries).to.be('function');
|
||||
});
|
|
@ -46,6 +46,25 @@ define(function (require) {
|
|||
};
|
||||
|
||||
var ordered = {};
|
||||
var childrenObject = {
|
||||
children: []
|
||||
};
|
||||
var seriesObject = {
|
||||
series: []
|
||||
};
|
||||
var rowsObject = {
|
||||
rows: []
|
||||
};
|
||||
var columnsObject = {
|
||||
columns: []
|
||||
};
|
||||
var emptyObject = {};
|
||||
var str = 'string';
|
||||
var number = 24;
|
||||
var boolean = false;
|
||||
var nullValue = null;
|
||||
var emptyArray = [];
|
||||
var notAValue;
|
||||
|
||||
describe('Zero Injection (main)', function () {
|
||||
var injectZeros;
|
||||
|
@ -64,6 +83,56 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if the input is not an object', function () {
|
||||
expect(function () {
|
||||
injectZeros(str);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(emptyArray);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should throw an error if property series, rows, or columns is not ' +
|
||||
'present', function () {
|
||||
|
||||
expect(function () {
|
||||
injectZeros(childrenObject);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should not throw an error if object has property series, rows, or ' +
|
||||
'columns', function () {
|
||||
|
||||
expect(function () {
|
||||
injectZeros(seriesObject);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(rowsObject);
|
||||
}).to.not.throwError();
|
||||
|
||||
expect(function () {
|
||||
injectZeros(columnsObject);
|
||||
}).to.not.throwError();
|
||||
});
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(_.isFunction(injectZeros)).to.be(true);
|
||||
});
|
||||
|
@ -118,6 +187,32 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an object', function () {
|
||||
expect(function () {
|
||||
orderXValues(str);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
orderXValues(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
orderXValues(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
orderXValues(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
orderXValues(emptyArray);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
orderXValues(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should return a function', function () {
|
||||
expect(_.isFunction(orderXValues)).to.be(true);
|
||||
});
|
||||
|
@ -150,6 +245,32 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an object', function () {
|
||||
expect(function () {
|
||||
uniqueKeys(str);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqueKeys(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqueKeys(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqueKeys(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqueKeys(emptyArray);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
uniqueKeys(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should return a function', function () {
|
||||
expect(_.isFunction(uniqueKeys)).to.be(true);
|
||||
});
|
||||
|
@ -212,6 +333,32 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input is not an array', function () {
|
||||
expect(function () {
|
||||
createZeroArray(str);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createZeroArray(number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createZeroArray(boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createZeroArray(nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createZeroArray(emptyObject);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
createZeroArray(notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should return a function', function () {
|
||||
expect(_.isFunction(createZeroArray)).to.be(true);
|
||||
});
|
||||
|
@ -275,6 +422,32 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should throw an error if input are not arrays', function () {
|
||||
expect(function () {
|
||||
zeroFillArray(str, str);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
zeroFillArray(number, number);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
zeroFillArray(boolean, boolean);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
zeroFillArray(nullValue, nullValue);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
zeroFillArray(emptyObject, emptyObject);
|
||||
}).to.throwError();
|
||||
|
||||
expect(function () {
|
||||
zeroFillArray(notAValue, notAValue);
|
||||
}).to.throwError();
|
||||
});
|
||||
|
||||
it('should return a function', function () {
|
||||
expect(_.isFunction(zeroFillArray)).to.be(true);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue