2021-07-01 14:03:02 +00:00
|
|
|
import TestState, { rectangleId, arrowId } from './test-utils'
|
2021-06-23 14:39:14 +00:00
|
|
|
|
|
|
|
describe('selection', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
const tt = new TestState()
|
|
|
|
|
2021-06-23 14:39:14 +00:00
|
|
|
it('selects a shape', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll().clickShape(rectangleId)
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
expect(tt.idsAreSelected([rectangleId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('selects and deselects a shape', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll().clickShape(rectangleId).clickCanvas()
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
expect(tt.idsAreSelected([])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('selects multiple shapes', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll()
|
|
|
|
.clickShape(rectangleId)
|
|
|
|
.clickShape(arrowId, { shiftKey: true })
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([rectangleId, arrowId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('shift-selects to deselect shapes', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll()
|
|
|
|
.clickShape(rectangleId)
|
|
|
|
.clickShape(arrowId, { shiftKey: true })
|
|
|
|
.clickShape(rectangleId, { shiftKey: true })
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([arrowId])).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('single-selects shape in selection on click', () => {
|
|
|
|
tt.deselectAll()
|
|
|
|
.clickShape(rectangleId)
|
|
|
|
.clickShape(arrowId, { shiftKey: true })
|
|
|
|
.clickShape(arrowId)
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([arrowId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
it('single-selects shape in selection on pointerup only', () => {
|
|
|
|
tt.deselectAll()
|
|
|
|
.clickShape(rectangleId)
|
|
|
|
.clickShape(arrowId, { shiftKey: true })
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
expect(tt.idsAreSelected([rectangleId, arrowId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.startClick(arrowId)
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
expect(tt.idsAreSelected([rectangleId, arrowId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.stopClick(arrowId)
|
2021-06-23 14:39:14 +00:00
|
|
|
|
2021-07-01 14:03:02 +00:00
|
|
|
expect(tt.idsAreSelected([arrowId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('selects shapes if shift key is lifted before pointerup', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll()
|
|
|
|
.clickShape(rectangleId)
|
|
|
|
.clickShape(arrowId, { shiftKey: true })
|
|
|
|
.startClick(rectangleId, { shiftKey: true })
|
|
|
|
.stopClick(rectangleId)
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([rectangleId])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it('does not select on meta-click', () => {
|
2021-07-01 14:03:02 +00:00
|
|
|
tt.deselectAll().clickShape(rectangleId, { ctrlKey: true })
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([])).toBe(true)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('does not select on meta-shift-click', () => {
|
|
|
|
tt.deselectAll().clickShape(rectangleId, { ctrlKey: true, shiftKey: true })
|
|
|
|
|
|
|
|
expect(tt.idsAreSelected([])).toBe(true)
|
2021-06-23 14:39:14 +00:00
|
|
|
})
|
|
|
|
})
|