[#88,state][s]: (and finally) introduce a recline.View.DataExplorer.restore function that restores from a serialized state.
* remove getState in favour of just using direct access to state object.
This commit is contained in:
@@ -15,7 +15,7 @@ test('basic explorer functionality', function () {
|
||||
$el.remove();
|
||||
});
|
||||
|
||||
test('getState', function () {
|
||||
test('get State', function () {
|
||||
var $el = $('<div class="test-view-explorer-getstate" />');
|
||||
$('.fixtures .data-explorer-here').append($el);
|
||||
var dataset = Fixture.getDataset();
|
||||
@@ -23,11 +23,13 @@ test('getState', function () {
|
||||
model: dataset,
|
||||
el: $el
|
||||
});
|
||||
var state = explorer.getState();
|
||||
var state = explorer.state;
|
||||
ok(state.get('query'));
|
||||
equal(state.get('readOnly'), false);
|
||||
equal(state.get('query').size, 100);
|
||||
deepEqual(state.get('view-grid').hiddenFields, []);
|
||||
equal(state.get('backend'), 'memory');
|
||||
ok(state.get('dataset').id !== null);
|
||||
$el.remove();
|
||||
});
|
||||
|
||||
@@ -42,8 +44,18 @@ test('initialize state', function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
var state = explorer.getState();
|
||||
ok(state.get('readOnly'));
|
||||
ok(explorer.state.get('readOnly'));
|
||||
});
|
||||
|
||||
test('restore (from serialized state)', function() {
|
||||
var dataset = Fixture.getDataset();
|
||||
var explorer = new recline.View.DataExplorer({
|
||||
model: dataset,
|
||||
});
|
||||
var state = explorer.state.toJSON();
|
||||
var explorerNew = recline.View.DataExplorer.restore(state);
|
||||
var out = explorerNew.state.toJSON();
|
||||
equal(out.backend, state.backend);
|
||||
});
|
||||
|
||||
})(this.jQuery);
|
||||
|
||||
Reference in New Issue
Block a user