UNPKG

overmind

Version:
53 lines 1.56 kB
import { Overmind, createOvermindSSR, json, rehydrate } from './'; describe('Mock', () => { test('should allow changing the state', () => { const state = { foo: 'bar', }; const config = { state, }; const overmind = 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 = 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 }) => { rehydrate(state, mutations); }, }; const config = { actions, state, }; const overmindSsr = createOvermindSSR(config); overmindSsr.state.foo = 'bar2'; mutations = overmindSsr.hydrate(); const overmind = new Overmind(config); expect(json(overmind.state)).toEqual({ foo: 'bar2', }); }); }); //# sourceMappingURL=ssr.test.js.map