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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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').send('MOUNTED_SHAPES')
  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('MOUNTED_SHAPES')
  23. .send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
  24. .send('CLEARED_PAGE')
  25. expect(
  26. state.data.document.pages[state.data.currentPageId].shapes
  27. ).toStrictEqual({})
  28. state
  29. .send('MOUNTED')
  30. .send('MOUNTED_SHAPES')
  31. .send('LOADED_FROM_FILE', { json: JSON.stringify(json) })
  32. expect(state.data.document).toMatchSnapshot('data after re-mount from file')
  33. })
  34. })