Skip to content

Commit

Permalink
fix: toFill doesn't empty contents when given an empty string (#381)
Browse files Browse the repository at this point in the history
Co-authored-by: Tony Brix <tony@brix.ninja>
  • Loading branch information
MatthiasEngh and UziTech authored Apr 16, 2021
1 parent a7b5693 commit 964b9a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/expect-puppeteer/src/matchers/toFill.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function toFill(instance, selector, value, options) {
toMatchElementOptions,
)
await element.click({ clickCount: 3 })
await element.press('Backspace')
await element.type(value, {
delay,
})
Expand Down
9 changes: 9 additions & 0 deletions packages/expect-puppeteer/src/matchers/toFill.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ describe('toFill', () => {
expect(value).toBe('James')
})

it('should empty the input given an empty string', async () => {
await expect(page).toFill('[name="firstName"]', 'James')
await expect(page).toFill('[name="firstName"]', '')
const value = await page.evaluate(
() => document.querySelector('[name="firstName"]').value,
)
expect(value).toBe('')
})

it('should return an error if text is not in the page', async () => {
expect.assertions(2)

Expand Down

0 comments on commit 964b9a2

Please sign in to comment.