mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
add global state test to ensure state is persisted from memory when missing from URL
This commit is contained in:
parent
dddadb8757
commit
2b479b72c5
2 changed files with 38 additions and 0 deletions
|
@ -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',
|
||||
|
|
37
test/unit/specs/state_management/global_state.js
Normal file
37
test/unit/specs/state_management/global_state.js
Normal 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' });
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue