@@ -49,14 +49,14 @@ describe('LiveController query string binding', () => {
4949 // String
5050
5151 // Set value
52- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
52+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?prop1=foo&prop2=' ) ;
5353
5454 await test . component . set ( 'prop1' , 'foo' , true ) ;
5555
5656 expectCurrentSearch ( ) . toEqual ( '?prop1=foo&prop2=' ) ;
5757
5858 // Remove value
59- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
59+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
6060
6161 await test . component . set ( 'prop1' , '' , true ) ;
6262
@@ -65,14 +65,14 @@ describe('LiveController query string binding', () => {
6565 // Number
6666
6767 // Set value
68- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) ;
68+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) . willReturnLiveUrl ( '?prop1=&prop2=42' ) ;
6969
7070 await test . component . set ( 'prop2' , 42 , true ) ;
7171
7272 expectCurrentSearch ( ) . toEqual ( '?prop1=&prop2=42' ) ;
7373
7474 // Remove value
75- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) ;
75+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
7676
7777 await test . component . set ( 'prop2' , null , true ) ;
7878
@@ -88,21 +88,25 @@ describe('LiveController query string binding', () => {
8888 ) ;
8989
9090 // Set value
91- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } ) ;
91+ test . expectsAjaxCall ( )
92+ . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } )
93+ . willReturnLiveUrl ( '?prop[0]=foo&prop[1]=bar' ) ;
9294
9395 await test . component . set ( 'prop' , [ 'foo' , 'bar' ] , true ) ;
9496
9597 expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo&prop[1]=bar' ) ;
9698
9799 // Remove one value
98- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' ] } ) ;
100+ test . expectsAjaxCall ( )
101+ . expectUpdatedData ( { prop : [ 'foo' ] } )
102+ . willReturnLiveUrl ( '?prop[0]=foo' ) ;
99103
100104 await test . component . set ( 'prop' , [ 'foo' ] , true ) ;
101105
102106 expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo' ) ;
103107
104108 // Remove all remaining values
105- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) ;
109+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) . willReturnLiveUrl ( '?prop=' ) ;
106110
107111 await test . component . set ( 'prop' , [ ] , true ) ;
108112
@@ -118,28 +122,34 @@ describe('LiveController query string binding', () => {
118122 ) ;
119123
120124 // Set single nested prop
121- test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) ;
125+ test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) . willReturnLiveUrl ( '?prop[foo]=dummy' ) ;
122126
123127 await test . component . set ( 'prop.foo' , 'dummy' , true ) ;
124128
125129 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=dummy' ) ;
126130
127131 // Set multiple values
128- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } ) ;
132+ test . expectsAjaxCall ( )
133+ . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } )
134+ . willReturnLiveUrl ( '?prop[foo]=other&prop[bar]=42' ) ;
129135
130136 await test . component . set ( 'prop' , { foo : 'other' , bar : 42 } , true ) ;
131137
132138 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other&prop[bar]=42' ) ;
133139
134140 // Remove one value
135- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } ) ;
141+ test . expectsAjaxCall ( )
142+ . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } )
143+ . willReturnLiveUrl ( '?prop[foo]=other' ) ;
136144
137145 await test . component . set ( 'prop' , { foo : 'other' , bar : null } , true ) ;
138146
139147 expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other' ) ;
140148
141149 // Remove all values
142- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : null , bar : null } } ) ;
150+ test . expectsAjaxCall ( )
151+ . expectUpdatedData ( { prop : { foo : null , bar : null } } )
152+ . willReturnLiveUrl ( '?prop=' ) ;
143153
144154 await test . component . set ( 'prop' , { foo : null , bar : null } , true ) ;
145155
@@ -161,13 +171,15 @@ describe('LiveController query string binding', () => {
161171 . expectActionCalled ( 'changeProp' )
162172 . serverWillChangeProps ( ( data : any ) => {
163173 data . prop = 'foo' ;
164- } ) ;
174+ } )
175+ . willReturnLiveUrl ( '?prop=foo' ) ;
165176
166177 getByText ( test . element , 'Change prop' ) . click ( ) ;
167178
168- await waitFor ( ( ) => expect ( test . element ) . toHaveTextContent ( 'Prop: foo' ) ) ;
169-
170- expectCurrentSearch ( ) . toEqual ( '?prop=foo' ) ;
179+ await waitFor ( ( ) => {
180+ expect ( test . element ) . toHaveTextContent ( 'Prop: foo' ) ;
181+ expectCurrentSearch ( ) . toEqual ( '?prop=foo' ) ;
182+ } ) ;
171183 } ) ;
172184
173185 it ( 'uses custom name instead of prop name in the URL' , async ( ) => {
@@ -179,14 +191,14 @@ describe('LiveController query string binding', () => {
179191 ) ;
180192
181193 // Set value
182- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
194+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?alias1=foo' ) ;
183195
184196 await test . component . set ( 'prop1' , 'foo' , true ) ;
185197
186198 expectCurrentSearch ( ) . toEqual ( '?alias1=foo' ) ;
187199
188200 // Remove value
189- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
201+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?alias1=' ) ;
190202
191203 await test . component . set ( 'prop1' , '' , true ) ;
192204
0 commit comments