Skip to content

Commit

Permalink
Merge pull request elastic#8123 from spalger/fix/configRaceInTests
Browse files Browse the repository at this point in the history
remove config.set() call to avoid race
  • Loading branch information
epixa authored Aug 30, 2016
2 parents c74f1f4 + a1fb323 commit 401dea9
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta

let $parentScope;
let $scope;
let config;
let hits;
let indexPattern;
let indexPatternList;
let shortDotsValue;

// Sets up the directive, take an element, and a list of properties to attach to the parent scope.
const init = function ($elem, props) {
ngMock.inject(function ($rootScope, $compile, $timeout, _config_) {
shortDotsValue = _config_.get('shortDots:enable');
config = _config_;
config.set('shortDots:enable', false);
ngMock.inject(function ($rootScope, $compile, $timeout) {
$parentScope = $rootScope;
_.assign($parentScope, props);
$compile($elem)($parentScope);
Expand All @@ -39,7 +34,6 @@ const init = function ($elem, props) {
const destroy = function () {
$scope.$destroy();
$parentScope.$destroy();
config.set('shortDots:enable', shortDotsValue);
};

describe('discover field chooser directives', function () {
Expand All @@ -56,7 +50,21 @@ describe('discover field chooser directives', function () {
'</disc-field-chooser>'
);

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.module('kibana', ($provide) => {
$provide.decorator('config', ($delegate) => {
// disable shortDots for these tests
$delegate.get = _.wrap($delegate.get, function (origGet, name) {
if (name === 'shortDots:enable') {
return false;
} else {
return origGet.call(this, name);
}
});

return $delegate;
});
}));

beforeEach(ngMock.inject(function (Private) {
hits = Private(FixturesHitsProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
Expand Down

0 comments on commit 401dea9

Please sign in to comment.