[filterBar] added tests to verify 0e306d4
This commit is contained in:
parent
0e306d4e6a
commit
65dc7679f4
|
@ -16,7 +16,7 @@ function stubbedLogstashFields() {
|
|||
{ name: 'extension', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: 'machine.os', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: 'geo.src', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_type', type: 'string', indexed: true, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_type', type: 'string', indexed: false, analyzed: true, sortable: true, filterable: true },
|
||||
{ name: '_id', type: 'string', indexed: false, analyzed: false, sortable: false, filterable: true},
|
||||
{ name: '_source', type: 'string', indexed: false, analyzed: false, sortable: false, filterable: false},
|
||||
{ name: 'custom_user_field', type: 'conflict', indexed: false, analyzed: false, sortable: false, filterable: true },
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
import ngMock from 'ng_mock';
|
||||
import expect from 'expect.js';
|
||||
|
||||
import MockState from 'fixtures/mock_state';
|
||||
import notify from 'ui/notify';
|
||||
import AggConfigResult from 'ui/vis/agg_config_result';
|
||||
|
||||
import VisProvider from 'ui/vis';
|
||||
import StubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
import FilterBarClickHandlerProvider from 'ui/filter_bar/filter_bar_click_handler';
|
||||
|
||||
describe('filterBarClickHandler', function () {
|
||||
let setup = null;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
setup = function () {
|
||||
const Vis = Private(VisProvider);
|
||||
const createClickHandler = Private(FilterBarClickHandlerProvider);
|
||||
const indexPattern = Private(StubbedLogstashIndexPatternProvider);
|
||||
|
||||
const vis = new Vis(indexPattern, {
|
||||
type: 'histogram',
|
||||
aggs: [
|
||||
{ type: 'count', schema: 'metric' },
|
||||
{
|
||||
type: 'terms',
|
||||
schema: 'segment',
|
||||
params: { field: '_type' }
|
||||
}
|
||||
]
|
||||
});
|
||||
const aggConfigResult = new AggConfigResult(vis.aggs[1], void 0, 'apache', 'apache');
|
||||
|
||||
const $state = new MockState({ filters: [] });
|
||||
const clickHandler = createClickHandler($state);
|
||||
|
||||
return { clickHandler, $state, aggConfigResult };
|
||||
};
|
||||
}));
|
||||
|
||||
afterEach(function () {
|
||||
notify._notifs.splice(0);
|
||||
});
|
||||
|
||||
context('on non-filterable fields', function () {
|
||||
it('warns about trying to filter on a non-filterable field', function () {
|
||||
const { clickHandler, aggConfigResult } = setup();
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
clickHandler({ point: { aggConfigResult }});
|
||||
expect(notify._notifs).to.have.length(1);
|
||||
});
|
||||
|
||||
it('does not warn if the event is click is being simulated', function () {
|
||||
const { clickHandler, aggConfigResult } = setup();
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
clickHandler({ point: { aggConfigResult }}, true);
|
||||
expect(notify._notifs).to.have.length(0);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue