mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[fixture/hits] wrap in private
wrapping to prevent sharing modifications. Since Private effectively clones the hits per test, changes made by one test can't impact another
This commit is contained in:
parent
b7e35e6737
commit
c90996e7e7
2 changed files with 30 additions and 23 deletions
|
@ -1,22 +1,24 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
return _.map([
|
||||
{_source: {'@timestamp': 0, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 10, request: 'foo'}},
|
||||
{_source: {'@timestamp': 1, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 20, request: 'bar'}},
|
||||
{_source: {'@timestamp': 2, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'bar'}},
|
||||
{_source: {'@timestamp': 3, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 4, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 5, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 6, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 7, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 8, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 9, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
], function (p, i) {
|
||||
return _.merge({}, p, {
|
||||
_score: 1,
|
||||
_id: 1000 + i,
|
||||
_type: 'test',
|
||||
_index: 'test-index'
|
||||
return function fitsFixture() {
|
||||
return _.map([
|
||||
{_source: {'@timestamp': 0, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 10, request: 'foo'}},
|
||||
{_source: {'@timestamp': 1, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 20, request: 'bar'}},
|
||||
{_source: {'@timestamp': 2, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'bar'}},
|
||||
{_source: {'@timestamp': 3, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 4, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 5, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 30, request: 'baz'}},
|
||||
{_source: {'@timestamp': 6, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 7, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 8, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
{_source: {'@timestamp': 9, ssl: true, ip: '192.168.0.1', extension: 'php', 'machine.os': 'Linux', bytes: 40.141592, request: 'bat'}},
|
||||
], function (p, i) {
|
||||
return _.merge({}, p, {
|
||||
_score: 1,
|
||||
_id: 1000 + i,
|
||||
_type: 'test',
|
||||
_index: 'test-index'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -8,7 +8,12 @@ define(function (require) {
|
|||
require('services/private');
|
||||
require('plugins/discover/components/field_chooser/field_chooser');
|
||||
|
||||
var $parentScope, $scope, config, indexPattern, indexPatternList;
|
||||
var $parentScope;
|
||||
var $scope;
|
||||
var config;
|
||||
var hits;
|
||||
var indexPattern;
|
||||
var indexPatternList;
|
||||
|
||||
// Sets up the directive, take an element, and a list of properties to attach to the parent scope.
|
||||
var init = function ($elem, props) {
|
||||
|
@ -48,16 +53,17 @@ define(function (require) {
|
|||
beforeEach(module('kibana'));
|
||||
beforeEach(function () {
|
||||
inject(function (Private) {
|
||||
hits = Private(require('fixtures/hits'));
|
||||
indexPattern = Private(require('fixtures/stubbed_logstash_index_pattern'));
|
||||
indexPatternList = [ 'b', 'a', 'c' ];
|
||||
});
|
||||
|
||||
var hits = _.each(require('fixtures/hits.js'), indexPattern.flattenHit);
|
||||
var flatHits = _.each(hits, indexPattern.flattenHit);
|
||||
|
||||
init($elem, {
|
||||
columns: [],
|
||||
toggle: sinon.spy(),
|
||||
data: hits,
|
||||
data: flatHits,
|
||||
filter: sinon.spy(),
|
||||
indexPattern: indexPattern,
|
||||
indexPatternList: indexPatternList
|
||||
|
@ -172,7 +178,6 @@ define(function (require) {
|
|||
});
|
||||
|
||||
it('should increase the field popularity when called', function (done) {
|
||||
var counter = field.count;
|
||||
indexPattern.popularizeField = sinon.spy();
|
||||
$scope.details(field);
|
||||
expect(indexPattern.popularizeField.called).to.be(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue