Replace deprecated Jest methods with the new methods (#3005)

* replace deprecated `lastCalledWith` with `toHaveBeenLastCalledWith`

* replace deprecated `toThrowError` with `toThrow`
This commit is contained in:
Robin Malfait
2024-02-21 14:28:19 +01:00
committed by GitHub
parent a50be9255a
commit 043edb8319
9 changed files with 34 additions and 36 deletions
@@ -98,7 +98,7 @@ describe('safeguards', () => {
])(
'should error when we are using a <%s /> without a parent <Combobox />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <Combobox /> component.`
)
})
@@ -6079,7 +6079,7 @@ describe('Form compatibility', () => {
// Submit the form
await click(getByText('Submit'))
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
it('should be possible to submit a form with a value', async () => {
@@ -6119,7 +6119,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([]) // no data
expect(submits).toHaveBeenLastCalledWith([]) // no data
// Open combobox again
await click(getComboboxButton())
@@ -6131,7 +6131,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
// Open combobox again
await click(getComboboxButton())
@@ -6143,7 +6143,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
it('should not submit the data if the Combobox is disabled', async () => {
@@ -6248,7 +6248,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -6265,7 +6265,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '2'],
['delivery[value]', 'home-delivery'],
['delivery[label]', 'Home delivery'],
@@ -6282,7 +6282,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -92,7 +92,7 @@ describe('Safe guards', () => {
])(
'should error when we are using a <%s /> without a parent <Dialog />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <Dialog /> component.`
)
expect.hasAssertions()
@@ -32,7 +32,7 @@ describe('Safe guards', () => {
])(
'should error when we are using a <%s /> without a parent <Disclosure />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <Disclosure /> component.`
)
})
@@ -74,7 +74,7 @@ describe('safeguards', () => {
])(
'should error when we are using a <%s /> without a parent <Listbox />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <Listbox /> component.`
)
})
@@ -5005,7 +5005,7 @@ describe('Form compatibility', () => {
// Submit the form
await click(getByText('Submit'))
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
it('should be possible to submit a form with a value', async () => {
@@ -5044,7 +5044,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([]) // no data
expect(submits).toHaveBeenLastCalledWith([]) // no data
// Open listbox again
await click(getListboxButton())
@@ -5056,7 +5056,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
// Open listbox again
await click(getListboxButton())
@@ -5068,7 +5068,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
it('should not submit the data if the Listbox is disabled', async () => {
@@ -5171,7 +5171,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -5188,7 +5188,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '2'],
['delivery[value]', 'home-delivery'],
['delivery[label]', 'Home delivery'],
@@ -5205,7 +5205,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -63,9 +63,7 @@ describe('Safe guards', () => {
])(
'should error when we are using a <%s /> without a parent <Menu />',
suppressConsoleLogs((name, component) => {
expect(() => render(component)).toThrowError(
`<${name} /> is missing a parent <Menu /> component.`
)
expect(() => render(component)).toThrow(`<${name} /> is missing a parent <Menu /> component.`)
})
)
@@ -45,7 +45,7 @@ describe('Safe guards', () => {
])(
'should error when we are using a <%s /> without a parent <Popover />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <Popover /> component.`
)
})
@@ -43,7 +43,7 @@ describe('Safe guards', () => {
it.each([['RadioGroupOption', RadioGroupOption]])(
'should error when we are using a <%s /> without a parent <RadioGroup />',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <RadioGroup /> component.`
)
})
@@ -1623,7 +1623,7 @@ describe('Form compatibility', () => {
// Submit the form
await click(getByText('Submit'))
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
)
@@ -1659,7 +1659,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([]) // no data
expect(submits).toHaveBeenLastCalledWith([]) // no data
// Choose home delivery
await click(getByText('Home delivery'))
@@ -1668,7 +1668,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
// Choose pickup
await click(getByText('Pickup'))
@@ -1677,7 +1677,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['delivery', 'pickup']])
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
})
it('should not submit the data if the RadioGroup is disabled', async () => {
@@ -1771,7 +1771,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -1785,7 +1785,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '2'],
['delivery[value]', 'home-delivery'],
['delivery[label]', 'Home delivery'],
@@ -1799,7 +1799,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([
expect(submits).toHaveBeenLastCalledWith([
['delivery[id]', '1'],
['delivery[value]', 'pickup'],
['delivery[label]', 'Pickup'],
@@ -845,7 +845,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['notifications', 'on']])
expect(submits).toHaveBeenLastCalledWith([['notifications', 'on']])
})
it('should be possible to submit a form with an boolean value', async () => {
@@ -877,7 +877,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([]) // no data
expect(submits).toHaveBeenLastCalledWith([]) // no data
// Toggle
await click(getSwitchLabel())
@@ -886,7 +886,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['notifications', 'on']])
expect(submits).toHaveBeenLastCalledWith([['notifications', 'on']])
})
it('should be possible to submit a form with a provided string value', async () => {
@@ -918,7 +918,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([]) // no data
expect(submits).toHaveBeenLastCalledWith([]) // no data
// Toggle
await click(getSwitchLabel())
@@ -927,7 +927,7 @@ describe('Form compatibility', () => {
await click(getByText('Submit'))
// Verify that the form has been submitted
expect(submits).lastCalledWith([['fruit', 'apple']])
expect(submits).toHaveBeenLastCalledWith([['fruit', 'apple']])
})
it('should not submit the data if the Switch is disabled', async () => {
@@ -32,7 +32,7 @@ describe('safeguards', () => {
])(
'should error when we are using a <%s /> without a parent <TabGroup /> component',
suppressConsoleLogs((name, Component) => {
expect(() => render(Component)).toThrowError(
expect(() => render(Component)).toThrow(
`<${name} /> is missing a parent <TabGroup /> component.`
)
})