kopia lustrzana https://github.com/Tldraw/Tldraw
55 wiersze
1.1 KiB
TypeScript
55 wiersze
1.1 KiB
TypeScript
import { TLDrawState } from '~state'
|
|
import { mockDocument } from '~test'
|
|
import {
|
|
ColorStyle,
|
|
DashStyle,
|
|
SessionType,
|
|
SizeStyle,
|
|
TLDrawShapeType,
|
|
TLDrawStatus,
|
|
} from '~types'
|
|
|
|
describe('Draw session', () => {
|
|
const state = new TLDrawState()
|
|
|
|
it('begins, updateSession', () => {
|
|
state.loadDocument(mockDocument)
|
|
|
|
expect(state.getShape('draw1')).toBe(undefined)
|
|
|
|
state
|
|
.createShapes({
|
|
id: 'draw1',
|
|
parentId: 'page1',
|
|
name: 'Draw',
|
|
childIndex: 5,
|
|
type: TLDrawShapeType.Draw,
|
|
point: [32, 32],
|
|
points: [[0, 0]],
|
|
style: {
|
|
dash: DashStyle.Draw,
|
|
size: SizeStyle.Medium,
|
|
color: ColorStyle.Blue,
|
|
},
|
|
})
|
|
.select('draw1')
|
|
.startSession(SessionType.Draw, [0, 0], 'draw1')
|
|
.updateSession([10, 10, 0.5])
|
|
.completeSession()
|
|
|
|
expect(state.appState.status).toBe(TLDrawStatus.Idle)
|
|
})
|
|
|
|
it('does, undoes and redoes', () => {
|
|
expect(state.getShape('draw1')).toBeTruthy()
|
|
|
|
state.undo()
|
|
|
|
expect(state.getShape('draw1')).toBe(undefined)
|
|
|
|
state.redo()
|
|
|
|
expect(state.getShape('draw1')).toBeTruthy()
|
|
})
|
|
})
|