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.

createShapes.spec.ts 839B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { TLDrawState } from '~state'
  2. import { mockDocument } from '~test'
  3. describe('Create command', () => {
  4. const tlstate = new TLDrawState()
  5. beforeEach(() => {
  6. tlstate.loadDocument(mockDocument)
  7. })
  8. describe('when no shape is provided', () => {
  9. it('does nothing', () => {
  10. const initialState = tlstate.state
  11. tlstate.create()
  12. const currentState = tlstate.state
  13. expect(currentState).toEqual(initialState)
  14. })
  15. })
  16. it('does, undoes and redoes command', () => {
  17. const shape = { ...tlstate.getShape('rect1'), id: 'rect4' }
  18. tlstate.create([shape])
  19. expect(tlstate.getShape('rect4')).toBeTruthy()
  20. tlstate.undo()
  21. expect(tlstate.getShape('rect4')).toBe(undefined)
  22. tlstate.redo()
  23. expect(tlstate.getShape('rect4')).toBeTruthy()
  24. })
  25. it.todo('Creates bindings')
  26. })