mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Tests for the fieldType filter
This commit is contained in:
parent
d27e4a5ba3
commit
dc1aafa746
4 changed files with 75 additions and 2 deletions
|
@ -1,3 +1,6 @@
|
|||
// Gets all fields of a given type.
|
||||
// You may also pass "*" to get all types
|
||||
// Or an array of types to get all fields of that type
|
||||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
|
||||
|
|
|
@ -27,12 +27,14 @@ define(function (require) {
|
|||
|
||||
$delegate.change = function (path) {
|
||||
if (path !== $location.path()) {
|
||||
$location.path(path); reload();
|
||||
$location.path(path);
|
||||
reload();
|
||||
}
|
||||
};
|
||||
$delegate.changeUrl = function (url) {
|
||||
if (url !== $location.url()) {
|
||||
$location.url(url); reload();
|
||||
$location.url(url);
|
||||
reload();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
'specs/directives/timepicker',
|
||||
'specs/directives/truncate',
|
||||
'specs/directives/css_truncate',
|
||||
'specs/filters/field_type',
|
||||
'specs/utils/datemath',
|
||||
'specs/utils/interval',
|
||||
], function (sinon) {
|
||||
|
|
67
test/unit/specs/filters/field_type.js
Normal file
67
test/unit/specs/filters/field_type.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
define(function (require) {
|
||||
var angular = require('angular');
|
||||
var mocks = require('angular-mocks');
|
||||
var _ = require('lodash');
|
||||
|
||||
// Load the kibana app dependencies.
|
||||
require('angular-route');
|
||||
|
||||
// Load kibana and its applications
|
||||
require('index');
|
||||
require('apps/discover/index');
|
||||
require('filters/field_type');
|
||||
|
||||
var filter, types;
|
||||
|
||||
var init = function (expandable) {
|
||||
// Load the application
|
||||
module('kibana');
|
||||
|
||||
types = [
|
||||
{name: 's1', type: 'string'},
|
||||
{name: 's2', type: 'string'},
|
||||
{name: 's3', type: 'string'},
|
||||
|
||||
{name: 'n1', type: 'number'},
|
||||
{name: 'n2', type: 'number'},
|
||||
|
||||
{name: 'i1', type: 'ip'},
|
||||
{name: 'd1', type: 'date'},
|
||||
];
|
||||
|
||||
// Create the scope
|
||||
inject(function ($filter) {
|
||||
filter = $filter('fieldType');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
describe('fieldType array filter', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
it('should have a fieldType filter', function () {
|
||||
expect(filter).to.not.be(null);
|
||||
});
|
||||
|
||||
it('should have 3 string fields', function () {
|
||||
expect(filter(types, 'string').length).to.be(3);
|
||||
});
|
||||
|
||||
it('should have 2 number fields', function () {
|
||||
expect(filter(types, 'number').length).to.be(2);
|
||||
});
|
||||
|
||||
it('should have 1 ip field and 1 date field', function () {
|
||||
expect(_.pluck(filter(types, ['date', 'ip']), 'name')).to.eql(['i1', 'd1']);
|
||||
});
|
||||
|
||||
it('should return all fields when passed *', function () {
|
||||
expect(filter(types, '*').length).to.be(7);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue