tldraw/__tests__/tools.test.ts
2021-07-13 20:34:43 +01:00

38 lines
840 B
TypeScript

import TestState from './test-utils'
const TOOLS = [
'draw',
'rectangle',
'ellipse',
'arrow',
'text',
'line',
'ray',
'dot',
]
describe('when selecting tools', () => {
const tt = new TestState()
TOOLS.forEach((tool) => {
it(`selects ${tool} tool`, () => {
tt.reset().send(`SELECTED_${tool.toUpperCase()}_TOOL`)
expect(tt.data.activeTool).toBe(tool)
expect(tt.state.isIn(tool)).toBe(true)
})
TOOLS.forEach((otherTool) => {
if (otherTool === tool) return
it(`selects ${tool} tool from ${otherTool} tool`, () => {
tt.reset()
.send(`SELECTED_${tool.toUpperCase()}_TOOL`)
.send(`SELECTED_${otherTool.toUpperCase()}_TOOL`)
expect(tt.data.activeTool).toBe(otherTool)
expect(tt.state.isIn(otherTool)).toBe(true)
})
})
})
})