add global state test to ensure state is persisted from memory when missing from URL

This commit is contained in:
Joe Fleming 2014-08-28 16:24:05 -07:00
parent dddadb8757
commit 2b479b72c5
2 changed files with 38 additions and 0 deletions

View file

@ -81,6 +81,7 @@
'specs/courier/search_source/_get_normalized_sort',
'specs/factories/base_object',
'specs/state_management/state',
'specs/state_management/global_state',
'specs/utils/diff_object',
'specs/utils/diff_time_picker_vals',
'specs/factories/events',

View file

@ -0,0 +1,37 @@
define(function (require) {
var sinon = require('sinon/sinon');
require('components/state_management/global_state');
// Load kibana
require('index');
describe('State Management', function () {
var $rootScope, $location, state;
beforeEach(function () {
module('kibana');
inject(function (_$location_, globalState) {
$location = _$location_;
state = globalState;
});
});
describe('Global State', function () {
it('should use previous state when not in URL', function () {
// set satte via URL
$location.search({ _g: '(foo:(bar:baz))' });
state.fetch();
expect(state.toObject()).to.eql({ foo: { bar: 'baz' } });
$location.search({ _g: '(fizz:buzz)' });
state.fetch();
expect(state.toObject()).to.eql({ fizz: 'buzz' });
$location.search({});
state.fetch();
expect(state.toObject()).to.eql({ fizz: 'buzz' });
});
});
});
});