@@ -64,57 +64,53 @@ test('renderAsync supports legacy rendering option', async () => {
6464 expect ( screen . root ) . toBeOnTheScreen ( ) ;
6565} ) ;
6666
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 /> ) ;
7269
73- expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
70+ expect ( ( ) => result . rerender ( < Banana /> ) ) . toThrowErrorMatchingInlineSnapshot (
71+ `"\`rerender(...)\` is not supported when using \`renderAsync\` use \`await rerenderAsync(...)\` instead"`
72+ ) ;
7473} ) ;
7574
76- test ( 'updateAsync function updates component asynchronously' , async ( ) => {
75+ test ( 'rerenderAsync function updates component asynchronously' , async ( ) => {
7776 const fn = jest . fn ( ) ;
7877 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 } /> ) ;
8281 expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
8382} ) ;
8483
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 /> ) ;
9086
91- expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
87+ expect ( ( ) => result . rerender ( < Banana /> ) ) . toThrowErrorMatchingInlineSnapshot (
88+ `"\`rerender(...)\` is not supported when using \`renderAsync\` use \`await rerenderAsync(...)\` instead"`
89+ ) ;
9290} ) ;
9391
94- test ( 'rerenderAsync is an alias for updateAsync ' , async ( ) => {
92+ test ( 'rerenderAsync function updates component asynchronously ' , async ( ) => {
9593 const fn = jest . fn ( ) ;
9694 const result = await renderAsync ( < Banana onUpdate = { fn } /> ) ;
97-
95+ expect ( fn ) . toHaveBeenCalledTimes ( 0 ) ;
96+
9897 await result . rerenderAsync ( < Banana onUpdate = { fn } /> ) ;
99-
10098 expect ( fn ) . toHaveBeenCalledTimes ( 1 ) ;
10199} ) ;
102100
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 /> ) ;
108103
109- expect ( fn ) . toHaveBeenCalled ( ) ;
104+ expect ( ( ) => result . unmount ( ) ) . toThrowErrorMatchingInlineSnapshot (
105+ `"\`unmount()\` is not supported when using \`renderAsync\` use \`await unmountAsync()\` instead"`
106+ ) ;
110107} ) ;
111108
112109test ( 'unmountAsync function unmounts component asynchronously' , async ( ) => {
113110 const fn = jest . fn ( ) ;
114111 const result = await renderAsync ( < Banana onUnmount = { fn } /> ) ;
115112
116113 await result . unmountAsync ( ) ;
117-
118114 expect ( fn ) . toHaveBeenCalled ( ) ;
119115} ) ;
120116
0 commit comments