Skip to content

Commit 043edb8

Browse files
authored
Replace deprecated Jest methods with the new methods (#3005)
* replace deprecated `lastCalledWith` with `toHaveBeenLastCalledWith` * replace deprecated `toThrowError` with `toThrow`
1 parent a50be92 commit 043edb8

File tree

9 files changed

+34
-36
lines changed

9 files changed

+34
-36
lines changed

packages/@headlessui-vue/src/components/combobox/combobox.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ describe('safeguards', () => {
9898
])(
9999
'should error when we are using a <%s /> without a parent <Combobox />',
100100
suppressConsoleLogs((name, Component) => {
101-
expect(() => render(Component)).toThrowError(
101+
expect(() => render(Component)).toThrow(
102102
`<${name} /> is missing a parent <Combobox /> component.`
103103
)
104104
})
@@ -6079,7 +6079,7 @@ describe('Form compatibility', () => {
60796079
// Submit the form
60806080
await click(getByText('Submit'))
60816081

6082-
expect(submits).lastCalledWith([['delivery', 'pickup']])
6082+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
60836083
})
60846084

60856085
it('should be possible to submit a form with a value', async () => {
@@ -6119,7 +6119,7 @@ describe('Form compatibility', () => {
61196119
await click(getByText('Submit'))
61206120

61216121
// Verify that the form has been submitted
6122-
expect(submits).lastCalledWith([]) // no data
6122+
expect(submits).toHaveBeenLastCalledWith([]) // no data
61236123

61246124
// Open combobox again
61256125
await click(getComboboxButton())
@@ -6131,7 +6131,7 @@ describe('Form compatibility', () => {
61316131
await click(getByText('Submit'))
61326132

61336133
// Verify that the form has been submitted
6134-
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
6134+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
61356135

61366136
// Open combobox again
61376137
await click(getComboboxButton())
@@ -6143,7 +6143,7 @@ describe('Form compatibility', () => {
61436143
await click(getByText('Submit'))
61446144

61456145
// Verify that the form has been submitted
6146-
expect(submits).lastCalledWith([['delivery', 'pickup']])
6146+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
61476147
})
61486148

61496149
it('should not submit the data if the Combobox is disabled', async () => {
@@ -6248,7 +6248,7 @@ describe('Form compatibility', () => {
62486248
await click(getByText('Submit'))
62496249

62506250
// Verify that the form has been submitted
6251-
expect(submits).lastCalledWith([
6251+
expect(submits).toHaveBeenLastCalledWith([
62526252
['delivery[id]', '1'],
62536253
['delivery[value]', 'pickup'],
62546254
['delivery[label]', 'Pickup'],
@@ -6265,7 +6265,7 @@ describe('Form compatibility', () => {
62656265
await click(getByText('Submit'))
62666266

62676267
// Verify that the form has been submitted
6268-
expect(submits).lastCalledWith([
6268+
expect(submits).toHaveBeenLastCalledWith([
62696269
['delivery[id]', '2'],
62706270
['delivery[value]', 'home-delivery'],
62716271
['delivery[label]', 'Home delivery'],
@@ -6282,7 +6282,7 @@ describe('Form compatibility', () => {
62826282
await click(getByText('Submit'))
62836283

62846284
// Verify that the form has been submitted
6285-
expect(submits).lastCalledWith([
6285+
expect(submits).toHaveBeenLastCalledWith([
62866286
['delivery[id]', '1'],
62876287
['delivery[value]', 'pickup'],
62886288
['delivery[label]', 'Pickup'],

packages/@headlessui-vue/src/components/dialog/dialog.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describe('Safe guards', () => {
9292
])(
9393
'should error when we are using a <%s /> without a parent <Dialog />',
9494
suppressConsoleLogs((name, Component) => {
95-
expect(() => render(Component)).toThrowError(
95+
expect(() => render(Component)).toThrow(
9696
`<${name} /> is missing a parent <Dialog /> component.`
9797
)
9898
expect.hasAssertions()

packages/@headlessui-vue/src/components/disclosure/disclosure.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('Safe guards', () => {
3232
])(
3333
'should error when we are using a <%s /> without a parent <Disclosure />',
3434
suppressConsoleLogs((name, Component) => {
35-
expect(() => render(Component)).toThrowError(
35+
expect(() => render(Component)).toThrow(
3636
`<${name} /> is missing a parent <Disclosure /> component.`
3737
)
3838
})

packages/@headlessui-vue/src/components/listbox/listbox.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('safeguards', () => {
7474
])(
7575
'should error when we are using a <%s /> without a parent <Listbox />',
7676
suppressConsoleLogs((name, Component) => {
77-
expect(() => render(Component)).toThrowError(
77+
expect(() => render(Component)).toThrow(
7878
`<${name} /> is missing a parent <Listbox /> component.`
7979
)
8080
})
@@ -5005,7 +5005,7 @@ describe('Form compatibility', () => {
50055005
// Submit the form
50065006
await click(getByText('Submit'))
50075007

5008-
expect(submits).lastCalledWith([['delivery', 'pickup']])
5008+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
50095009
})
50105010

50115011
it('should be possible to submit a form with a value', async () => {
@@ -5044,7 +5044,7 @@ describe('Form compatibility', () => {
50445044
await click(getByText('Submit'))
50455045

50465046
// Verify that the form has been submitted
5047-
expect(submits).lastCalledWith([]) // no data
5047+
expect(submits).toHaveBeenLastCalledWith([]) // no data
50485048

50495049
// Open listbox again
50505050
await click(getListboxButton())
@@ -5056,7 +5056,7 @@ describe('Form compatibility', () => {
50565056
await click(getByText('Submit'))
50575057

50585058
// Verify that the form has been submitted
5059-
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
5059+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
50605060

50615061
// Open listbox again
50625062
await click(getListboxButton())
@@ -5068,7 +5068,7 @@ describe('Form compatibility', () => {
50685068
await click(getByText('Submit'))
50695069

50705070
// Verify that the form has been submitted
5071-
expect(submits).lastCalledWith([['delivery', 'pickup']])
5071+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
50725072
})
50735073

50745074
it('should not submit the data if the Listbox is disabled', async () => {
@@ -5171,7 +5171,7 @@ describe('Form compatibility', () => {
51715171
await click(getByText('Submit'))
51725172

51735173
// Verify that the form has been submitted
5174-
expect(submits).lastCalledWith([
5174+
expect(submits).toHaveBeenLastCalledWith([
51755175
['delivery[id]', '1'],
51765176
['delivery[value]', 'pickup'],
51775177
['delivery[label]', 'Pickup'],
@@ -5188,7 +5188,7 @@ describe('Form compatibility', () => {
51885188
await click(getByText('Submit'))
51895189

51905190
// Verify that the form has been submitted
5191-
expect(submits).lastCalledWith([
5191+
expect(submits).toHaveBeenLastCalledWith([
51925192
['delivery[id]', '2'],
51935193
['delivery[value]', 'home-delivery'],
51945194
['delivery[label]', 'Home delivery'],
@@ -5205,7 +5205,7 @@ describe('Form compatibility', () => {
52055205
await click(getByText('Submit'))
52065206

52075207
// Verify that the form has been submitted
5208-
expect(submits).lastCalledWith([
5208+
expect(submits).toHaveBeenLastCalledWith([
52095209
['delivery[id]', '1'],
52105210
['delivery[value]', 'pickup'],
52115211
['delivery[label]', 'Pickup'],

packages/@headlessui-vue/src/components/menu/menu.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ describe('Safe guards', () => {
6363
])(
6464
'should error when we are using a <%s /> without a parent <Menu />',
6565
suppressConsoleLogs((name, component) => {
66-
expect(() => render(component)).toThrowError(
67-
`<${name} /> is missing a parent <Menu /> component.`
68-
)
66+
expect(() => render(component)).toThrow(`<${name} /> is missing a parent <Menu /> component.`)
6967
})
7068
)
7169

packages/@headlessui-vue/src/components/popover/popover.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Safe guards', () => {
4545
])(
4646
'should error when we are using a <%s /> without a parent <Popover />',
4747
suppressConsoleLogs((name, Component) => {
48-
expect(() => render(Component)).toThrowError(
48+
expect(() => render(Component)).toThrow(
4949
`<${name} /> is missing a parent <Popover /> component.`
5050
)
5151
})

packages/@headlessui-vue/src/components/radio-group/radio-group.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Safe guards', () => {
4343
it.each([['RadioGroupOption', RadioGroupOption]])(
4444
'should error when we are using a <%s /> without a parent <RadioGroup />',
4545
suppressConsoleLogs((name, Component) => {
46-
expect(() => render(Component)).toThrowError(
46+
expect(() => render(Component)).toThrow(
4747
`<${name} /> is missing a parent <RadioGroup /> component.`
4848
)
4949
})
@@ -1623,7 +1623,7 @@ describe('Form compatibility', () => {
16231623
// Submit the form
16241624
await click(getByText('Submit'))
16251625

1626-
expect(submits).lastCalledWith([['delivery', 'pickup']])
1626+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
16271627
})
16281628
)
16291629

@@ -1659,7 +1659,7 @@ describe('Form compatibility', () => {
16591659
await click(getByText('Submit'))
16601660

16611661
// Verify that the form has been submitted
1662-
expect(submits).lastCalledWith([]) // no data
1662+
expect(submits).toHaveBeenLastCalledWith([]) // no data
16631663

16641664
// Choose home delivery
16651665
await click(getByText('Home delivery'))
@@ -1668,7 +1668,7 @@ describe('Form compatibility', () => {
16681668
await click(getByText('Submit'))
16691669

16701670
// Verify that the form has been submitted
1671-
expect(submits).lastCalledWith([['delivery', 'home-delivery']])
1671+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'home-delivery']])
16721672

16731673
// Choose pickup
16741674
await click(getByText('Pickup'))
@@ -1677,7 +1677,7 @@ describe('Form compatibility', () => {
16771677
await click(getByText('Submit'))
16781678

16791679
// Verify that the form has been submitted
1680-
expect(submits).lastCalledWith([['delivery', 'pickup']])
1680+
expect(submits).toHaveBeenLastCalledWith([['delivery', 'pickup']])
16811681
})
16821682

16831683
it('should not submit the data if the RadioGroup is disabled', async () => {
@@ -1771,7 +1771,7 @@ describe('Form compatibility', () => {
17711771
await click(getByText('Submit'))
17721772

17731773
// Verify that the form has been submitted
1774-
expect(submits).lastCalledWith([
1774+
expect(submits).toHaveBeenLastCalledWith([
17751775
['delivery[id]', '1'],
17761776
['delivery[value]', 'pickup'],
17771777
['delivery[label]', 'Pickup'],
@@ -1785,7 +1785,7 @@ describe('Form compatibility', () => {
17851785
await click(getByText('Submit'))
17861786

17871787
// Verify that the form has been submitted
1788-
expect(submits).lastCalledWith([
1788+
expect(submits).toHaveBeenLastCalledWith([
17891789
['delivery[id]', '2'],
17901790
['delivery[value]', 'home-delivery'],
17911791
['delivery[label]', 'Home delivery'],
@@ -1799,7 +1799,7 @@ describe('Form compatibility', () => {
17991799
await click(getByText('Submit'))
18001800

18011801
// Verify that the form has been submitted
1802-
expect(submits).lastCalledWith([
1802+
expect(submits).toHaveBeenLastCalledWith([
18031803
['delivery[id]', '1'],
18041804
['delivery[value]', 'pickup'],
18051805
['delivery[label]', 'Pickup'],

packages/@headlessui-vue/src/components/switch/switch.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ describe('Form compatibility', () => {
845845
await click(getByText('Submit'))
846846

847847
// Verify that the form has been submitted
848-
expect(submits).lastCalledWith([['notifications', 'on']])
848+
expect(submits).toHaveBeenLastCalledWith([['notifications', 'on']])
849849
})
850850

851851
it('should be possible to submit a form with an boolean value', async () => {
@@ -877,7 +877,7 @@ describe('Form compatibility', () => {
877877
await click(getByText('Submit'))
878878

879879
// Verify that the form has been submitted
880-
expect(submits).lastCalledWith([]) // no data
880+
expect(submits).toHaveBeenLastCalledWith([]) // no data
881881

882882
// Toggle
883883
await click(getSwitchLabel())
@@ -886,7 +886,7 @@ describe('Form compatibility', () => {
886886
await click(getByText('Submit'))
887887

888888
// Verify that the form has been submitted
889-
expect(submits).lastCalledWith([['notifications', 'on']])
889+
expect(submits).toHaveBeenLastCalledWith([['notifications', 'on']])
890890
})
891891

892892
it('should be possible to submit a form with a provided string value', async () => {
@@ -918,7 +918,7 @@ describe('Form compatibility', () => {
918918
await click(getByText('Submit'))
919919

920920
// Verify that the form has been submitted
921-
expect(submits).lastCalledWith([]) // no data
921+
expect(submits).toHaveBeenLastCalledWith([]) // no data
922922

923923
// Toggle
924924
await click(getSwitchLabel())
@@ -927,7 +927,7 @@ describe('Form compatibility', () => {
927927
await click(getByText('Submit'))
928928

929929
// Verify that the form has been submitted
930-
expect(submits).lastCalledWith([['fruit', 'apple']])
930+
expect(submits).toHaveBeenLastCalledWith([['fruit', 'apple']])
931931
})
932932

933933
it('should not submit the data if the Switch is disabled', async () => {

packages/@headlessui-vue/src/components/tabs/tabs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('safeguards', () => {
3232
])(
3333
'should error when we are using a <%s /> without a parent <TabGroup /> component',
3434
suppressConsoleLogs((name, Component) => {
35-
expect(() => render(Component)).toThrowError(
35+
expect(() => render(Component)).toThrow(
3636
`<${name} /> is missing a parent <TabGroup /> component.`
3737
)
3838
})

0 commit comments

Comments
 (0)