Fixes up editorState - ensures that it is set in all of the correct places (removes appState editingEntity and references), ensures that setting 'current' is not possible, ensures that editorState is reset on all route changes, adds unit tests for getting/setting editorState.

This commit is contained in:
Shannon
2013-11-19 10:39:18 +11:00
parent 89b20a2e77
commit 5bb68f32bf
8 changed files with 81 additions and 46 deletions

View File

@@ -1,13 +1,32 @@
describe('appState tests', function () {
var appState, $rootScope;
var appState, $rootScope, editorState;
beforeEach(module('umbraco.services'));
beforeEach(inject(function ($injector) {
appState = $injector.get('appState');
$rootScope = $injector.get('$rootScope');
editorState = $injector.get('editorState');
}));
describe('Editor state', function () {
it('Can set', function () {
editorState.set({ some: "object" });
expect(editorState.current).not.toBeNull();
expect(editorState.current.some).toBe("object");
});
it('Can reset', function () {
editorState.reset();
expect(editorState.current).toBeNull();
});
it('Throws when setting current', function () {
function setCurrent() {
editorState.current = { some: "object" };
}
expect(setCurrent).toThrow();
});
});
describe('Global state', function () {
it('Can get/set state', function () {
appState.setGlobalState("showNavigation", true);