Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
commit
03634b1ca3
11340 files changed
+3442369
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { lastInputModality } from './input-modality'
|
||||
|
||||
describe('lastInputModality', () => {
|
||||
it('defaults to keyboard before any input', () => {
|
||||
expect(lastInputModality()).toBe('keyboard')
|
||||
})
|
||||
|
||||
it('tracks the device behind the last interaction', () => {
|
||||
document.dispatchEvent(new Event('pointerdown'))
|
||||
|
||||
expect(lastInputModality()).toBe('pointer')
|
||||
|
||||
document.dispatchEvent(new Event('keydown'))
|
||||
|
||||
expect(lastInputModality()).toBe('keyboard')
|
||||
})
|
||||
|
||||
it('sees events a handler stops from bubbling (capture phase)', () => {
|
||||
const target = document.createElement('button')
|
||||
|
||||
document.body.append(target)
|
||||
target.addEventListener('pointerdown', event => event.stopPropagation())
|
||||
target.dispatchEvent(new Event('pointerdown', { bubbles: true }))
|
||||
|
||||
expect(lastInputModality()).toBe('pointer')
|
||||
|
||||
target.remove()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user