Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

create-page.test.ts 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import TestState from '../test-utils'
  2. describe('create page command', () => {
  3. const tt = new TestState()
  4. tt.resetDocumentState().save()
  5. describe('creates a page', () => {
  6. it('does command', () => {
  7. expect(Object.keys(tt.data.document.pages).length).toBe(1)
  8. tt.send('CREATED_PAGE')
  9. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  10. })
  11. it('changes to the new page', () => {
  12. tt.restore().send('CREATED_PAGE')
  13. const pageId = Object.keys(tt.data.document.pages)[1]
  14. expect(tt.data.currentPageId).toBe(pageId)
  15. })
  16. it('un-does command', () => {
  17. tt.restore().send('CREATED_PAGE').undo()
  18. expect(Object.keys(tt.data.document.pages).length).toBe(1)
  19. const pageId = Object.keys(tt.data.document.pages)[0]
  20. expect(tt.data.currentPageId).toBe(pageId)
  21. })
  22. it('re-does command', () => {
  23. tt.restore().send('CREATED_PAGE').undo().redo()
  24. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  25. const pageId = Object.keys(tt.data.document.pages)[1]
  26. expect(tt.data.currentPageId).toBe(pageId)
  27. })
  28. })
  29. })