Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ import {render, screen} from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import userEvent from '@testing-library/user-event'

it('should cycle elements in document tab order', () => {
it('cycle elements in document tab order', () => {
render(
<div>
<input data-testid="element" type="checkbox" />
Expand Down Expand Up @@ -510,7 +510,7 @@ Unhovers out of `element`.
Allows you to simulate the user pasting some text into an input.

```javascript
test('should paste text in input', () => {
test('paste text in input', () => {
render(<MyInput />)

const text = 'Hello, world!'
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ test('clicking a disabled radio button only fires pointer events', () => {
expect(element).not.toBeChecked()
})

test('should fire the correct events for <div>', () => {
test('fire the correct events for <div>', () => {
const {element, getEventSnapshot} = setup('<div></div>')
userEvent.click(element)
expect(getEventSnapshot()).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -166,7 +166,7 @@ test('toggles the focus', () => {
expect(b).toHaveFocus()
})

test('should blur the previous element', () => {
test('blur the previous element', () => {
const {element, getEventSnapshot, clearEventCalls} = setup(
`<div><input name="a" /><input name="b" /></div>`,
)
Expand Down Expand Up @@ -204,7 +204,7 @@ test('should blur the previous element', () => {
expect(bListeners.eventWasFired('focus')).toBe(true)
})

test('should not blur the previous element when mousedown prevents default', () => {
test('does not blur the previous element when mousedown prevents default', () => {
const {element, getEventSnapshot, clearEventCalls} = setup(
`<div><input name="a" /><input name="b" /></div>`,
)
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/paste.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import userEvent from '../'
import {setup} from './helpers/utils'

test('should paste text in input', () => {
test('paste text in input', () => {
const {element, getEventSnapshot} = setup('<input />')

const text = 'Hello, world!'
Expand All @@ -19,7 +19,7 @@ test('should paste text in input', () => {
`)
})

test('should paste text in textarea', () => {
test('paste text in textarea', () => {
const {element, getEventSnapshot} = setup('<textarea />')

const text = 'Hello, world!'
Expand Down Expand Up @@ -60,7 +60,7 @@ test('does not paste when disabled', () => {
})

test.each(['input', 'textarea'])(
'should paste text in <%s> up to maxLength if provided',
'paste text in <%s> up to maxLength if provided',
type => {
const {element} = setup(`<${type} maxlength="10" />`)

Expand All @@ -74,7 +74,7 @@ test.each(['input', 'textarea'])(
)

test.each(['input', 'textarea'])(
'should append text in <%s> up to maxLength if provided',
'append text in <%s> up to maxLength if provided',
type => {
const {element} = setup(`<${type} maxlength="10" />`)

Expand All @@ -88,7 +88,7 @@ test.each(['input', 'textarea'])(
},
)

test('should replace selected text all at once', () => {
test('replace selected text all at once', () => {
const {element} = setup('<input value="hello world" />')

const selectionStart = 'hello world'.search('world')
Expand All @@ -98,7 +98,7 @@ test('should replace selected text all at once', () => {
expect(element).toHaveValue('hello friend')
})

test('should give error if we are trying to call paste on an invalid element', () => {
test('give error if we are trying to call paste on an invalid element', () => {
const {element} = setup('<div />')
expect(() =>
userEvent.paste(element, "I'm only a div :("),
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/select-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ test('does not select anything if options are disabled', () => {
expect(o3.selected).toBe(false)
})

test('should call onChange/input bubbling up the event when a new option is selected', () => {
test('call onChange/input bubbling up the event when a new option is selected', () => {
const {select, form} = setupSelect({multiple: true})
const onChangeSelect = jest.fn()
const onChangeForm = jest.fn()
Expand Down
22 changes: 11 additions & 11 deletions src/__tests__/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test('fires correct events with shift key', () => {
expect(bListeners.eventWasFired('blur')).toBe(true)
})

test('should cycle elements in document tab order', () => {
test('cycle elements in document tab order', () => {
setup(`
<div>
<input data-testid="element" type="checkbox" />
Expand Down Expand Up @@ -119,7 +119,7 @@ test('should cycle elements in document tab order', () => {
expect(checkbox).toHaveFocus()
})

test('should go backwards when shift = true', () => {
test('go backwards when shift = true', () => {
setup(`
<div>
<input data-testid="element" type="checkbox" />
Expand Down Expand Up @@ -155,7 +155,7 @@ test('should go backwards when shift = true', () => {
expect(number).toHaveFocus()
})

test('should respect tabindex, regardless of dom position', () => {
test('respect tabindex, regardless of dom position', () => {
setup(`
<div>
<input data-testid="element" tabIndex="2" type="checkbox" />
Expand Down Expand Up @@ -188,7 +188,7 @@ test('should respect tabindex, regardless of dom position', () => {
expect(radio).toHaveFocus()
})

test('should respect tab index order, then DOM order', () => {
test('respect tab index order, then DOM order', () => {
setup(`
<div>
<input data-testid="element" tabIndex="0" type="checkbox" />
Expand Down Expand Up @@ -221,7 +221,7 @@ test('should respect tab index order, then DOM order', () => {
expect(checkbox).toHaveFocus()
})

test('should support a mix of elements with/without tab index', () => {
test('support a mix of elements with/without tab index', () => {
setup(`
<div>
<input data-testid="element" tabIndex="0" type="checkbox" />
Expand Down Expand Up @@ -265,7 +265,7 @@ test('ignore tabindex when active element has tabindex="-1"', () => {
expect(inputD).toHaveFocus()
})

test('should not tab to <a> with no href', () => {
test('does not tab to <a> with no href', () => {
setup(`
<div>
<input data-testid="element" tabIndex="0" type="checkbox" />
Expand All @@ -287,7 +287,7 @@ test('should not tab to <a> with no href', () => {
expect(link).toHaveFocus()
})

test('should not tab to <input> with type="hidden"', () => {
test('does not tab to <input> with type="hidden"', () => {
const {
elements: [checkbox, , text],
} = setup(`
Expand All @@ -305,7 +305,7 @@ test('should not tab to <input> with type="hidden"', () => {
expect(text).toHaveFocus()
})

test('should stay within a focus trap', () => {
test('stay within a focus trap', () => {
setup(`
<>
<div data-testid="div1">
Expand Down Expand Up @@ -376,7 +376,7 @@ test('should stay within a focus trap', () => {
// for example under node 10 in this test:
// > 'abcdefghijklmnopqrstuvwxyz'.split('').sort(() => 0).join('')
// will give you 'nacdefghijklmbopqrstuvwxyz'
test('should support unstable sorting environments like node 10', () => {
test('support unstable sorting environments like node 10', () => {
const letters = 'abcdefghijklmnopqrstuvwxyz'

setup(`
Expand All @@ -396,7 +396,7 @@ test('should support unstable sorting environments like node 10', () => {
}
})

test('should not focus disabled elements', () => {
test('does not focus disabled elements', () => {
setup(`
<div>
<input data-testid="one" />
Expand All @@ -418,7 +418,7 @@ test('should not focus disabled elements', () => {
expect(five).toHaveFocus()
})

test('should keep focus on the document if there are no enabled, focusable elements', () => {
test('keep focus on the document if there are no enabled, focusable elements', () => {
setup(`<button disabled>no clicky</button>`)
userEvent.tab()
expect(document.body).toHaveFocus()
Expand Down
24 changes: 12 additions & 12 deletions src/__tests__/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ test('does not fire input when readonly', () => {
`)
})

test('should delay the typing when opts.delay is not 0', async () => {
test('delay the typing when opts.delay is not 0', async () => {
const inputValues = [{timestamp: Date.now(), value: ''}]
const onInput = jest.fn(event => {
inputValues.push({timestamp: Date.now(), value: event.target.value})
Expand Down Expand Up @@ -361,7 +361,7 @@ test('ignores maxlength on input[type=number]', () => {
expect(element).toHaveValue(123)
})

test('should fire events on the currently focused element', () => {
test('fire events on the currently focused element', () => {
const {element} = setup(`<div><input /><input /></div>`, {
eventHandlers: {keyDown: handleKeyDown},
})
Expand All @@ -384,7 +384,7 @@ test('should fire events on the currently focused element', () => {
expect(input2).toHaveFocus()
})

test('should replace selected text', () => {
test('replace selected text', () => {
const {element} = setup('<input value="hello world" />')
const selectionStart = 'hello world'.search('world')
const selectionEnd = selectionStart + 'world'.length
Expand Down Expand Up @@ -803,7 +803,7 @@ test('typing an invalid input value', () => {
expect(element.validity.badInput).toBe(false)
})

test('should not throw error if we are trying to call type on an element without a value', () => {
test('does not throw error if we are trying to call type on an element without a value', () => {
const {element} = setup('<div />')
expect.assertions(0)
return userEvent
Expand Down Expand Up @@ -853,7 +853,7 @@ test('typing on input type file should not result in an error', () => {
return userEvent.type(element, 'bar').catch(e => expect(e).toBeUndefined())
})

test('should submit a form containing multiple text inputs and an input of type submit', () => {
test('submit a form containing multiple text inputs and an input of type submit', () => {
const handleSubmit = jest.fn()
const {element} = setup(
`
Expand All @@ -872,7 +872,7 @@ test('should submit a form containing multiple text inputs and an input of type
expect(handleSubmit).toHaveBeenCalledTimes(1)
})

test('should submit a form containing multiple text inputs and a submit button', () => {
test('submit a form containing multiple text inputs and a submit button', () => {
const handleSubmit = jest.fn()

const {element} = setup(
Expand All @@ -892,7 +892,7 @@ test('should submit a form containing multiple text inputs and a submit button',
expect(handleSubmit).toHaveBeenCalledTimes(1)
})

test('should submit a form with one input element', () => {
test('submit a form with one input element', () => {
const handleSubmit = jest.fn()

const {element} = setup(
Expand All @@ -910,7 +910,7 @@ test('should submit a form with one input element', () => {
expect(handleSubmit).toHaveBeenCalledTimes(1)
})

test('should not submit a form with when keydown calls prevent default', () => {
test('does not submit a form with when keydown calls prevent default', () => {
const handleSubmit = jest.fn()

const {element} = setup(
Expand All @@ -928,7 +928,7 @@ test('should not submit a form with when keydown calls prevent default', () => {
expect(handleSubmit).not.toHaveBeenCalled()
})

test('should not submit a form with when keypress calls prevent default', () => {
test('does not submit a form with when keypress calls prevent default', () => {
const handleSubmit = jest.fn()

const {element} = setup(
Expand All @@ -946,7 +946,7 @@ test('should not submit a form with when keypress calls prevent default', () =>
expect(handleSubmit).not.toHaveBeenCalled()
})

test('should not submit a form with multiple input when ENTER is pressed on one of it', () => {
test('does not submit a form with multiple input when ENTER is pressed on one of it', () => {
const handleSubmit = jest.fn()
const {element} = setup(
`
Expand All @@ -964,7 +964,7 @@ test('should not submit a form with multiple input when ENTER is pressed on one
expect(handleSubmit).toHaveBeenCalledTimes(0)
})

test('should type inside a contenteditable div', () => {
test('type inside a contenteditable div', () => {
const {element, getEventSnapshot} = setup('<div contenteditable=true></div>')

userEvent.type(element, 'bar')
Expand Down Expand Up @@ -1001,7 +1001,7 @@ test('should type inside a contenteditable div', () => {
expect(element).toHaveTextContent('bar')
})

test('should not type inside a contenteditable=false div', () => {
test('does not type inside a contenteditable=false div', () => {
const {element, getEventSnapshot} = setup('<div contenteditable=false></div>')

userEvent.type(element, 'bar')
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/upload.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import userEvent from '../'
import {setup, addListeners} from './helpers/utils'

test('should fire the correct events for input', () => {
test('fire the correct events for input', () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})
const {element, getEventSnapshot} = setup('<input type="file" />')

Expand Down Expand Up @@ -35,7 +35,7 @@ test('should fire the correct events for input', () => {
`)
})

test('should fire the correct events with label', () => {
test('fire the correct events with label', () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})

const {element, getEventSnapshot} = setup(`
Expand Down Expand Up @@ -68,7 +68,7 @@ test('should fire the correct events with label', () => {
`)
})

test('should upload the file', () => {
test('upload the file', () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})
const {element} = setup('<input type="file" />')

Expand All @@ -79,7 +79,7 @@ test('should upload the file', () => {
expect(element.files).toHaveLength(1)
})

test('should upload multiple files', () => {
test('upload multiple files', () => {
const files = [
new File(['hello'], 'hello.png', {type: 'image/png'}),
new File(['there'], 'there.png', {type: 'image/png'}),
Expand All @@ -95,7 +95,7 @@ test('should upload multiple files', () => {
expect(element.files).toHaveLength(2)
})

test('should upload multiple files when firing on the label', () => {
test('upload multiple files when firing on the label', () => {
const files = [
new File(['hello'], 'hello.png', {type: 'image/png'}),
new File(['there'], 'there.png', {type: 'image/png'}),
Expand All @@ -119,7 +119,7 @@ test('should upload multiple files when firing on the label', () => {
expect(input.files).toHaveLength(2)
})

test('should not upload when is disabled', () => {
test('does not upload when is disabled', () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})
const {element} = setup('<input type="file" disabled />')

Expand All @@ -130,7 +130,7 @@ test('should not upload when is disabled', () => {
expect(element.files).toHaveLength(0)
})

test('should call onChange/input bubbling up the event when a file is selected', () => {
test('call onChange/input bubbling up the event when a file is selected', () => {
const file = new File(['hello'], 'hello.png', {type: 'image/png'})

const {element: form} = setup(`
Expand Down
Loading