mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 21:12:44 +03:00
Fix selection tests (#9240)
Sometimes our test realizes, that `currentTarget` of `MouseEvent` is a read-only property. I have no idea why it does not do it every time, but this fix should work.
This commit is contained in:
parent
4316709379
commit
55f3820cf9
@ -1,6 +1,6 @@
|
||||
import { Rect } from '@/util/data/rect'
|
||||
import { Vec2 } from '@/util/data/vec2'
|
||||
import { expect, test } from 'vitest'
|
||||
import { expect, test, vi } from 'vitest'
|
||||
import { proxyRefs, ref, type Ref } from 'vue'
|
||||
import { useSelection } from '../selection'
|
||||
|
||||
@ -23,7 +23,7 @@ function selectionWithMockData(sceneMousePos?: Ref<Vec2>) {
|
||||
|
||||
// TODO[ao]: Skipping test, as they often fail in CI
|
||||
// (for example https://github.com/enso-org/enso/actions/runs/8102076908/job/22163122663)
|
||||
test.skip.each`
|
||||
test.each`
|
||||
click | modifiers | expected
|
||||
${1} | ${[]} | ${[1]}
|
||||
${3} | ${[]} | ${[3]}
|
||||
@ -54,7 +54,7 @@ const areas: Record<string, Rect> = {
|
||||
|
||||
// TODO[ao]: Skipping test, as they often fail in CI
|
||||
// (for example https://github.com/enso-org/enso/actions/runs/8102076908/job/22163122663)
|
||||
test.skip.each`
|
||||
test.each`
|
||||
areaId | modifiers | expected
|
||||
${'left'} | ${[]} | ${[1, 3]}
|
||||
${'right'} | ${[]} | ${[2, 4]}
|
||||
@ -103,12 +103,12 @@ test.skip.each`
|
||||
dragCase(new Vec2(area.right, area.top), new Vec2(area.left, area.bottom))
|
||||
})
|
||||
|
||||
// There is no PointerEvent class in jsdom (yet).
|
||||
class MockPointerEvent extends MouseEvent {
|
||||
currentTarget: EventTarget | null
|
||||
pointerId: number
|
||||
readonly pointerId: number
|
||||
constructor(type: string, options: MouseEventInit & { currentTarget?: Element | undefined }) {
|
||||
super(type, options)
|
||||
this.currentTarget = options.currentTarget ?? null
|
||||
vi.spyOn(this, 'currentTarget', 'get').mockReturnValue(options.currentTarget ?? null)
|
||||
this.pointerId = 4
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user