mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
add tests around getSort.array
also include test using the new 3rd asDefaultSort param
This commit is contained in:
parent
f17a1806ed
commit
48b139ec6b
1 changed files with 24 additions and 7 deletions
|
@ -4,14 +4,13 @@ define(function (require) {
|
|||
var indexPattern;
|
||||
|
||||
describe('docTable', function () {
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(inject(function (Private, _$rootScope_, Promise) {
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
}));
|
||||
|
||||
describe('getSort function', function () {
|
||||
|
||||
beforeEach(module('kibana'));
|
||||
|
||||
beforeEach(inject(function (Private, _$rootScope_, Promise) {
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
}));
|
||||
|
||||
it('should be a function', function () {
|
||||
expect(getSort).to.be.a(Function);
|
||||
});
|
||||
|
@ -63,9 +62,27 @@ define(function (require) {
|
|||
});
|
||||
});
|
||||
|
||||
it('should mimic normal sorting given a third truthy parameter', function () {
|
||||
expect(getSort(['script number', 'asc'], indexPattern, true)).to.eql({ 'script number': 'asc' });
|
||||
});
|
||||
|
||||
it('should sort by the default when passed an unsortable scripted field', function () {
|
||||
expect(getSort(['script murmur3', 'asc'], indexPattern)).to.eql(defaultSort);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSort.array function', function () {
|
||||
it('should have an array method', function () {
|
||||
expect(getSort.array).to.be.a(Function);
|
||||
});
|
||||
|
||||
it('should return an array for sortable fields', function () {
|
||||
expect(getSort.array(['bytes', 'desc'], indexPattern)).to.eql([ 'bytes', 'desc' ]);
|
||||
});
|
||||
|
||||
it('should return an array for scripted fields', function () {
|
||||
expect(getSort.array(['script string', 'asc'], indexPattern)).to.eql([ 'script string', 'asc' ]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue