Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Oct 19, 2021
1 parent 4f942a1 commit fb1b5be
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/__tests__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,26 @@ test('maintain `keyboardState` through different api calls', async () => {
// if the state is shared through api the already pressed `b` is automatically released
expect(getEvents('keyup')).toHaveLength(3)
})

test('maintain `pointerState` through different api calls', async () => {
const {element, getEvents} = setup<HTMLInputElement>(`<input/>`)

const api = userEvent.setup()

expect(api.pointer({keys: '[MouseLeft>]', target: element})).toBe(undefined)

expect(getSpy('pointer')).toBeCalledTimes(1)
expect(getEvents('mousedown')).toHaveLength(1)
expect(getEvents('mouseup')).toHaveLength(0)

await expect(api.pointer('[/MouseLeft]', {delay: 1})).resolves.toBe(undefined)

expect(getSpy('pointer')).toBeCalledTimes(2)
expect(getEvents('mousedown')).toHaveLength(1)
expect(getEvents('mouseup')).toHaveLength(1)

api.setup({}).pointer({target: element.ownerDocument.body})

expect(getSpy('pointer')).toBeCalledTimes(3)
expect(getEvents('mouseleave')).toHaveLength(1)
})

0 comments on commit fb1b5be

Please sign in to comment.