You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

project.test.ts 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import state from 'state'
  2. import * as json from './__mocks__/document.json'
  3. describe('project', () => {
  4. state.reset()
  5. state.enableLog(true)
  6. it('mounts the state', () => {
  7. state.send('MOUNTED')
  8. expect(state.isIn('ready')).toBe(true)
  9. })
  10. it('loads file from json', () => {
  11. state.send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
  12. expect(state.isIn('ready')).toBe(true)
  13. expect(state.data.document).toMatchSnapshot('data after mount from file')
  14. })
  15. })
  16. describe('restoring project', () => {
  17. state.reset()
  18. state.enableLog(true)
  19. it('remounts the state after mutating the current state', () => {
  20. state
  21. .send('MOUNTED')
  22. .send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
  23. .send('CLEARED_PAGE')
  24. expect(
  25. state.data.document.pages[state.data.currentPageId].shapes
  26. ).toStrictEqual({})
  27. state
  28. .send('MOUNTED')
  29. .send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
  30. expect(state.data.document).toMatchSnapshot('data after re-mount from file')
  31. })
  32. })