@@ -64,57 +64,53 @@ test('renderAsync supports legacy rendering option', async () => {
64
64
expect ( screen . root ) . toBeOnTheScreen ( ) ;
65
65
} ) ;
66
66
67
- test ( 'update function updates component synchronously' , async ( ) => {
68
- const fn = jest . fn ( ) ;
69
- const result = await renderAsync ( < Banana onUpdate = { fn } /> ) ;
70
-
71
- result . update ( < Banana onUpdate = { fn } /> ) ;
67
+ test ( 'rerender function throws error when used with renderAsync' , async ( ) => {
68
+ const result = await renderAsync ( < Banana /> ) ;
72
69
73
- expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
70
+ expect ( ( ) => result . rerender ( < Banana /> ) ) . toThrowErrorMatchingInlineSnapshot (
71
+ `"\`rerender(...)\` is not supported when using \`renderAsync\` use \`await rerenderAsync(...)\` instead"`
72
+ ) ;
74
73
} ) ;
75
74
76
- test ( 'updateAsync function updates component asynchronously' , async ( ) => {
75
+ test ( 'rerenderAsync function updates component asynchronously' , async ( ) => {
77
76
const fn = jest . fn ( ) ;
78
77
const result = await renderAsync ( < Banana onUpdate = { fn } /> ) ;
79
-
80
- await result . updateAsync ( < Banana onUpdate = { fn } /> ) ;
81
-
78
+ expect ( fn ) . toHaveBeenCalledTimes ( 0 ) ;
79
+
80
+ await result . rerenderAsync ( < Banana onUpdate = { fn } /> ) ;
82
81
expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
83
82
} ) ;
84
83
85
- test ( 'rerender is an alias for update' , async ( ) => {
86
- const fn = jest . fn ( ) ;
87
- const result = await renderAsync ( < Banana onUpdate = { fn } /> ) ;
88
-
89
- result . rerender ( < Banana onUpdate = { fn } /> ) ;
84
+ test ( 'rerender function throws error when used with renderAsync' , async ( ) => {
85
+ const result = await renderAsync ( < Banana /> ) ;
90
86
91
- expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
87
+ expect ( ( ) => result . rerender ( < Banana /> ) ) . toThrowErrorMatchingInlineSnapshot (
88
+ `"\`rerender(...)\` is not supported when using \`renderAsync\` use \`await rerenderAsync(...)\` instead"`
89
+ ) ;
92
90
} ) ;
93
91
94
- test ( 'rerenderAsync is an alias for updateAsync ' , async ( ) => {
92
+ test ( 'rerenderAsync function updates component asynchronously ' , async ( ) => {
95
93
const fn = jest . fn ( ) ;
96
94
const result = await renderAsync ( < Banana onUpdate = { fn } /> ) ;
97
-
95
+ expect ( fn ) . toHaveBeenCalledTimes ( 0 ) ;
96
+
98
97
await result . rerenderAsync ( < Banana onUpdate = { fn } /> ) ;
99
-
100
98
expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
101
99
} ) ;
102
100
103
- test ( 'unmount function unmounts component synchronously' , async ( ) => {
104
- const fn = jest . fn ( ) ;
105
- const result = await renderAsync ( < Banana onUnmount = { fn } /> ) ;
106
-
107
- result . unmount ( ) ;
101
+ test ( 'unmount function throws error when used with renderAsync' , async ( ) => {
102
+ const result = await renderAsync ( < Banana /> ) ;
108
103
109
- expect ( fn ) . toHaveBeenCalled ( ) ;
104
+ expect ( ( ) => result . unmount ( ) ) . toThrowErrorMatchingInlineSnapshot (
105
+ `"\`unmount()\` is not supported when using \`renderAsync\` use \`await unmountAsync()\` instead"`
106
+ ) ;
110
107
} ) ;
111
108
112
109
test ( 'unmountAsync function unmounts component asynchronously' , async ( ) => {
113
110
const fn = jest . fn ( ) ;
114
111
const result = await renderAsync ( < Banana onUnmount = { fn } /> ) ;
115
112
116
113
await result . unmountAsync ( ) ;
117
-
118
114
expect ( fn ) . toHaveBeenCalled ( ) ;
119
115
} ) ;
120
116
0 commit comments