2021-06-23 12:46:16 +00:00
|
|
|
import state from 'state'
|
2021-06-23 14:39:14 +00:00
|
|
|
import * as json from './__mocks__/document.json'
|
2021-06-23 12:46:16 +00:00
|
|
|
|
|
|
|
describe('project', () => {
|
2021-06-23 14:39:14 +00:00
|
|
|
state.reset()
|
|
|
|
state.enableLog(true)
|
2021-06-23 12:46:16 +00:00
|
|
|
|
2021-06-23 14:39:14 +00:00
|
|
|
it('mounts the state', () => {
|
|
|
|
state.send('MOUNTED')
|
2021-07-01 14:03:02 +00:00
|
|
|
|
2021-06-23 14:39:14 +00:00
|
|
|
expect(state.isIn('ready')).toBe(true)
|
2021-06-23 12:46:16 +00:00
|
|
|
})
|
|
|
|
|
2021-06-23 14:39:14 +00:00
|
|
|
it('loads file from json', () => {
|
|
|
|
state.send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
|
2021-07-01 14:03:02 +00:00
|
|
|
|
2021-06-23 14:39:14 +00:00
|
|
|
expect(state.isIn('ready')).toBe(true)
|
|
|
|
expect(state.data.document).toMatchSnapshot('data after mount from file')
|
2021-06-23 12:46:16 +00:00
|
|
|
})
|
|
|
|
})
|
2021-07-01 14:03:02 +00:00
|
|
|
|
|
|
|
describe('restoring project', () => {
|
|
|
|
state.reset()
|
|
|
|
state.enableLog(true)
|
|
|
|
|
|
|
|
it('remounts the state after mutating the current state', () => {
|
|
|
|
state
|
|
|
|
.send('MOUNTED')
|
|
|
|
.send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
|
|
|
|
.send('CLEARED_PAGE')
|
|
|
|
|
|
|
|
expect(
|
|
|
|
state.data.document.pages[state.data.currentPageId].shapes
|
|
|
|
).toStrictEqual({})
|
|
|
|
|
|
|
|
state
|
|
|
|
.send('MOUNTED')
|
|
|
|
.send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
|
|
|
|
|
|
|
|
expect(state.data.document).toMatchSnapshot('data after re-mount from file')
|
|
|
|
})
|
|
|
|
})
|