@@ -50,14 +50,14 @@ describe('LiveController query string binding', () => {
5050 // String
5151
5252 // Set value
53- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
53+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?prop1=foo&prop2=' ) ;
5454
5555 await test . component . set ( 'prop1' , 'foo' , true ) ;
5656
5757 expectCurrentSearch ( ) . toEqual ( '?prop1=foo&prop2=' ) ;
5858
5959 // Remove value
60- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
60+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
6161
6262 await test . component . set ( 'prop1' , '' , true ) ;
6363
@@ -66,14 +66,14 @@ describe('LiveController query string binding', () => {
6666 // Number
6767
6868 // Set value
69- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) ;
69+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) . willReturnLiveUrl ( '?prop1=&prop2=42' ) ;
7070
7171 await test . component . set ( 'prop2' , 42 , true ) ;
7272
7373 expectCurrentSearch ( ) . toEqual ( '?prop1=&prop2=42' ) ;
7474
7575 // Remove value
76- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) ;
76+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
7777
7878 await test . component . set ( 'prop2' , null , true ) ;
7979
@@ -89,21 +89,25 @@ describe('LiveController query string binding', () => {
8989 ) ;
9090
9191 // Set value
92- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } ) ;
92+ test . expectsAjaxCall ( )
93+ . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } )
94+ . willReturnLiveUrl ( '?prop[0]=foo&prop[1]=bar' ) ;
9395
9496 await test . component . set ( 'prop' , [ 'foo' , 'bar' ] , true ) ;
9597
9698 expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo&prop[1]=bar' ) ;
9799
98100 // Remove one value
99- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' ] } ) ;
101+ test . expectsAjaxCall ( )
102+ . expectUpdatedData ( { prop : [ 'foo' ] } )
103+ . willReturnLiveUrl ( '?prop[0]=foo' ) ;
100104
101105 await test . component . set ( 'prop' , [ 'foo' ] , true ) ;
102106
103107 expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo' ) ;
104108
105109 // Remove all remaining values
106- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) ;
110+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) . willReturnLiveUrl ( '?prop=' ) ;
107111
108112 await test . component . set ( 'prop' , [ ] , true ) ;
109113
@@ -119,28 +123,34 @@ describe('LiveController query string binding', () => {
119123 ) ;
120124
121125 // Set single nested prop
122- test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) ;
126+ test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) . willReturnLiveUrl ( '?prop[foo]=dummy' ) ;
123127
124128 await test . component . set ( 'prop.foo' , 'dummy' , true ) ;
125129
126130 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=dummy' ) ;
127131
128132 // Set multiple values
129- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } ) ;
133+ test . expectsAjaxCall ( )
134+ . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } )
135+ . willReturnLiveUrl ( '?prop[foo]=other&prop[bar]=42' ) ;
130136
131137 await test . component . set ( 'prop' , { foo : 'other' , bar : 42 } , true ) ;
132138
133139 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other&prop[bar]=42' ) ;
134140
135141 // Remove one value
136- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } ) ;
142+ test . expectsAjaxCall ( )
143+ . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } )
144+ . willReturnLiveUrl ( '?prop[foo]=other' ) ;
137145
138146 await test . component . set ( 'prop' , { foo : 'other' , bar : null } , true ) ;
139147
140148 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other' ) ;
141149
142150 // Remove all values
143- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : null , bar : null } } ) ;
151+ test . expectsAjaxCall ( )
152+ . expectUpdatedData ( { prop : { foo : null , bar : null } } )
153+ . willReturnLiveUrl ( '?prop=' ) ;
144154
145155 await test . component . set ( 'prop' , { foo : null , bar : null } , true ) ;
146156
@@ -162,13 +172,15 @@ describe('LiveController query string binding', () => {
162172 . expectActionCalled ( 'changeProp' )
163173 . serverWillChangeProps ( ( data : any ) => {
164174 data . prop = 'foo' ;
165- } ) ;
175+ } )
176+ . willReturnLiveUrl ( '?prop=foo' ) ;
166177
167178 getByText ( test . element , 'Change prop' ) . click ( ) ;
168179
169- await waitFor ( ( ) => expect ( test . element ) . toHaveTextContent ( 'Prop: foo' ) ) ;
170-
171- expectCurrentSearch ( ) . toEqual ( '?prop=foo' ) ;
180+ await waitFor ( ( ) => {
181+ expect ( test . element ) . toHaveTextContent ( 'Prop: foo' ) ;
182+ expectCurrentSearch ( ) . toEqual ( '?prop=foo' ) ;
183+ } ) ;
172184 } ) ;
173185
174186 it ( 'uses custom name instead of prop name in the URL' , async ( ) => {
@@ -180,14 +192,14 @@ describe('LiveController query string binding', () => {
180192 ) ;
181193
182194 // Set value
183- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
195+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?alias1=foo' ) ;
184196
185197 await test . component . set ( 'prop1' , 'foo' , true ) ;
186198
187199 expectCurrentSearch ( ) . toEqual ( '?alias1=foo' ) ;
188200
189201 // Remove value
190- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
202+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?alias1=' ) ;
191203
192204 await test . component . set ( 'prop1' , '' , true ) ;
193205
0 commit comments