Skip to content

Commit

Permalink
test: test driven
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jun 25, 2024
1 parent d9b97a3 commit d69552d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/components/number-keyboard/tests/number-keyboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,34 @@ describe('NumberKeyboard', () => {
expect(right).toBeInTheDocument()
expect(screen.getByTitle('0')).not.toHaveClass(`${classPrefix}-key-mid`)
})

test('long press backspace and release', () => {
const onDelete = jest.fn()
const { container } = render(<NumberKeyboard visible onDelete={onDelete} />)

// Fire touchstart event
fireEvent.touchStart(
document.body.querySelector(
'.adm-number-keyboard-key-sign'
) as HTMLDivElement,
{ touches: [{}] }
)
onDelete.mockReset()

jest.advanceTimersByTime(10000)
expect(onDelete).toHaveBeenCalled()
onDelete.mockReset()

// We do not fire touchend event to mock ISO missing touchend event
// Press other key
fireEvent.touchStart(
document.body.querySelector(
'.adm-number-keyboard-key-number'
) as HTMLDivElement,
{ touches: [{}] }
)

jest.advanceTimersByTime(10000)
expect(onDelete).not.toHaveBeenCalled()
})
})

0 comments on commit d69552d

Please sign in to comment.