remove duplicate filter toggle tests

This commit is contained in:
Joe Fleming 2015-04-15 11:34:57 -07:00
parent 0554d7a531
commit 10ff03d54d
2 changed files with 0 additions and 133 deletions

View file

@ -1,84 +0,0 @@
define(function (require) {
describe('Filter Bar Directive', function () {
var toggleAll = require('components/filter_bar/lib/toggleAll');
var _ = require('lodash');
var sinon = require('test_utils/auto_release_sinon');
var mapFilter, $rootScope, $compile, Promise, getIndexPatternStub, indexPattern;
beforeEach(module('kibana'));
beforeEach(function () {
getIndexPatternStub = sinon.stub();
module('kibana/courier', function ($provide) {
$provide.service('courier', function () {
var courier = { indexPatterns: { get: getIndexPatternStub } };
return courier;
});
});
});
beforeEach(inject(function (_Promise_, _$rootScope_, _$compile_, Private) {
Promise = _Promise_;
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
getIndexPatternStub.returns(Promise.resolve(indexPattern));
$rootScope = _$rootScope_;
$compile = _$compile_;
$rootScope.state = {
filters: [
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'apache' } } } },
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'nginx' } } } },
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
{ meta: { index: 'logstash-*', disabled: true }, missing: { field: 'host' } },
]
};
}));
describe('toggleAll', function () {
var fn;
beforeEach(function (done) {
var _filters = _($rootScope.state.filters)
.filter(function (filter) { return filter; })
.flatten(true)
.value();
Promise.map(_filters, mapFilter).then(function (filters) {
$rootScope.filters = filters;
done();
});
$rootScope.$apply();
});
beforeEach(function () {
fn = toggleAll($rootScope);
});
var pickDisabled = function (filter) {
return filter.meta.disabled;
};
it('should toggle all the filters', function () {
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(1);
fn();
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(3);
});
it('should disable all the filters', function () {
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(1);
fn(true);
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(4);
});
it('should enable all the filters', function () {
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(1);
fn(false);
expect(_.filter($rootScope.state.filters, pickDisabled)).to.have.length(0);
});
});
});
});

View file

@ -1,49 +0,0 @@
define(function (require) {
describe('Filter Bar Directive', function () {
var sinon = require('test_utils/auto_release_sinon');
var toggleFilter = require('components/filter_bar/lib/toggleFilter');
var $rootScope, $compile, mapFilter, getIndexPatternStub, indexPattern;
beforeEach(module('kibana'));
beforeEach(function () {
getIndexPatternStub = sinon.stub();
module('kibana/courier', function ($provide) {
$provide.service('courier', function () {
var courier = { indexPatterns: { get: getIndexPatternStub } };
return courier;
});
});
});
beforeEach(inject(function (Promise, Private, _$rootScope_, _$compile_) {
mapFilter = Private(require('components/filter_bar/lib/mapFilter'));
$rootScope = _$rootScope_;
$compile = _$compile_;
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
getIndexPatternStub.returns(Promise.resolve(indexPattern));
$rootScope.state = {
filters: [
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'apache' } } } },
{ meta: { index: 'logstash-*' }, query: { match: { '_type': { query: 'nginx' } } } },
{ meta: { index: 'logstash-*' }, exists: { field: '@timestamp' } },
{ missing: { field: 'host' }, meta: { disabled: true, index: 'logstash-*' } },
]
};
}));
describe('toggleFilter', function () {
it('should toggle filters on and off', function (done) {
var filter = $rootScope.state.filters[0];
var fn = toggleFilter($rootScope);
mapFilter(filter).then(fn).then(function (result) {
expect(result.meta).to.have.property('disabled', true);
done();
});
$rootScope.$apply();
});
});
});
});