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.

delete-page.test.ts 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import TestState from '../test-utils'
  2. describe('delete page command', () => {
  3. const tt = new TestState()
  4. tt.resetDocumentState().save()
  5. it('does command', () => {
  6. tt.reset().restore().send('CREATED_PAGE')
  7. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  8. const pageId = Object.keys(tt.data.document.pages)[1]
  9. tt.send('DELETED_PAGE', { id: pageId })
  10. expect(Object.keys(tt.data.document.pages).length).toBe(1)
  11. const firstPageId = Object.keys(tt.data.document.pages)[0]
  12. expect(tt.data.currentPageId).toBe(firstPageId)
  13. })
  14. it('un-does command', () => {
  15. tt.reset().restore().send('CREATED_PAGE')
  16. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  17. const pageId = Object.keys(tt.data.document.pages)[1]
  18. tt.send('DELETED_PAGE', { id: pageId }).undo()
  19. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  20. expect(tt.data.currentPageId).toBe(pageId)
  21. })
  22. it('re-does command', () => {
  23. tt.reset().restore().send('CREATED_PAGE')
  24. expect(Object.keys(tt.data.document.pages).length).toBe(2)
  25. const pageId = Object.keys(tt.data.document.pages)[1]
  26. tt.send('DELETED_PAGE', { id: pageId }).undo().redo()
  27. expect(Object.keys(tt.data.document.pages).length).toBe(1)
  28. const firstPageId = Object.keys(tt.data.document.pages)[0]
  29. expect(tt.data.currentPageId).toBe(firstPageId)
  30. })
  31. describe('when first page is selected', () => {
  32. it('does command', () => {
  33. // TODO
  34. null
  35. })
  36. it('un-does command', () => {
  37. // TODO
  38. null
  39. })
  40. it('re-does command', () => {
  41. // TODO
  42. null
  43. })
  44. })
  45. describe('when project only has one page', () => {
  46. it('does command', () => {
  47. // TODO
  48. null
  49. })
  50. it('un-does command', () => {
  51. // TODO
  52. null
  53. })
  54. it('re-does command', () => {
  55. // TODO
  56. null
  57. })
  58. })
  59. })