diff --git a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/get_sort.js b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/get_sort.js index f140b8b89a400..d5485bca33cf5 100644 --- a/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/get_sort.js +++ b/src/legacy/core_plugins/kibana/public/discover/__tests__/doc_table/lib/get_sort.js @@ -23,7 +23,6 @@ import ngMock from 'ng_mock'; import { getSort } from '../../../np_ready/angular/doc_table/lib/get_sort'; import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern'; -const defaultSort = [{ time: 'desc' }]; let indexPattern; describe('docTable', function() { @@ -51,21 +50,21 @@ describe('docTable', function() { expect(getSort([{ bytes: 'desc' }], indexPattern)).to.eql([{ bytes: 'desc' }]); }); - it('should sort by the default when passed an unsortable field', function() { - expect(getSort(['non-sortable', 'asc'], indexPattern)).to.eql(defaultSort); - expect(getSort(['lol_nope', 'asc'], indexPattern)).to.eql(defaultSort); + it('should return an empty array when passed an unsortable field', function() { + expect(getSort(['non-sortable', 'asc'], indexPattern)).to.eql([]); + expect(getSort(['lol_nope', 'asc'], indexPattern)).to.eql([]); delete indexPattern.timeFieldName; expect(getSort(['non-sortable', 'asc'], indexPattern)).to.eql([]); }); - it('should sort in reverse chrono order otherwise on time based patterns', function() { - expect(getSort([], indexPattern)).to.eql(defaultSort); - expect(getSort(['foo'], indexPattern)).to.eql(defaultSort); - expect(getSort({ foo: 'bar' }, indexPattern)).to.eql(defaultSort); + it('should return an empty array ', function() { + expect(getSort([], indexPattern)).to.eql([]); + expect(getSort(['foo'], indexPattern)).to.eql([]); + expect(getSort({ foo: 'bar' }, indexPattern)).to.eql([]); }); - it('should sort by score on non-time patterns', function() { + it('should return an empty array on non-time patterns', function() { delete indexPattern.timeFieldName; expect(getSort([], indexPattern)).to.eql([]); @@ -87,16 +86,16 @@ describe('docTable', function() { expect(getSort.array([{ bytes: 'desc' }], indexPattern)).to.eql([['bytes', 'desc']]); }); - it('should sort by the default when passed an unsortable field', function() { - expect(getSort.array([{ 'non-sortable': 'asc' }], indexPattern)).to.eql([['time', 'desc']]); - expect(getSort.array([{ lol_nope: 'asc' }], indexPattern)).to.eql([['time', 'desc']]); + it('should sort by an empty array when an unsortable field is given', function() { + expect(getSort.array([{ 'non-sortable': 'asc' }], indexPattern)).to.eql([]); + expect(getSort.array([{ lol_nope: 'asc' }], indexPattern)).to.eql([]); delete indexPattern.timeFieldName; expect(getSort.array([{ 'non-sortable': 'asc' }], indexPattern)).to.eql([]); }); - it('should sort by the default when passed an empty sort', () => { - expect(getSort.array([], indexPattern)).to.eql([['time', 'desc']]); + it('should return an empty array when passed an empty sort array', () => { + expect(getSort.array([], indexPattern)).to.eql([]); delete indexPattern.timeFieldName; expect(getSort.array([], indexPattern)).to.eql([]); diff --git a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/lib/get_sort.js b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/lib/get_sort.js index 4cf48b79c5b15..ce32fdaeda237 100644 --- a/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/lib/get_sort.js +++ b/src/legacy/core_plugins/kibana/public/discover/np_ready/angular/doc_table/lib/get_sort.js @@ -53,8 +53,8 @@ export function getSort(sort, indexPattern) { return []; } -getSort.array = function(sort, indexPattern, defaultSortOrder, useDefault = true) { - return getSort(sort, indexPattern, defaultSortOrder, useDefault).map(sortPair => +getSort.array = function(sort, indexPattern) { + return getSort(sort, indexPattern).map(sortPair => _(sortPair) .pairs() .pop()