UNPKG

overmind

Version:
55 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const _1 = require("./"); describe('Mock', () => { test('should allow changing the state', () => { const state = { foo: 'bar', }; const config = { state, }; const overmind = (0, _1.createOvermindSSR)(config); overmind.state.foo = 'bar2'; expect(overmind.state).toEqual({ foo: 'bar2', }); }); test('should return a tree of changes', () => { const state = { foo: 'bar', }; const config = { state, }; const overmind = (0, _1.createOvermindSSR)(config); overmind.state.foo = 'bar2'; const mutations = overmind.hydrate(); expect(mutations[0].method).toBe('set'); expect(mutations[0].path).toBe('foo'); expect(mutations[0].args).toEqual(['bar2']); }); test('should rehydrate mutation', () => { let mutations = []; const state = { foo: 'bar', }; const actions = { onInitializeOvermind: ({ state }) => { (0, _1.rehydrate)(state, mutations); }, }; const config = { actions, state, }; const overmindSsr = (0, _1.createOvermindSSR)(config); overmindSsr.state.foo = 'bar2'; mutations = overmindSsr.hydrate(); const overmind = new _1.Overmind(config); expect((0, _1.json)(overmind.state)).toEqual({ foo: 'bar2', }); }); }); //# sourceMappingURL=ssr.test.js.map