@@ -50,14 +50,14 @@ describe('LiveController query string binding', () => {
50
50
// String
51
51
52
52
// Set value
53
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
53
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?prop1=foo&prop2=' ) ;
54
54
55
55
await test . component . set ( 'prop1' , 'foo' , true ) ;
56
56
57
57
expectCurrentSearch ( ) . toEqual ( '?prop1=foo&prop2=' ) ;
58
58
59
59
// Remove value
60
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
60
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
61
61
62
62
await test . component . set ( 'prop1' , '' , true ) ;
63
63
@@ -66,14 +66,14 @@ describe('LiveController query string binding', () => {
66
66
// Number
67
67
68
68
// Set value
69
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) ;
69
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) . willReturnLiveUrl ( '?prop1=&prop2=42' ) ;
70
70
71
71
await test . component . set ( 'prop2' , 42 , true ) ;
72
72
73
73
expectCurrentSearch ( ) . toEqual ( '?prop1=&prop2=42' ) ;
74
74
75
75
// Remove value
76
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) ;
76
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
77
77
78
78
await test . component . set ( 'prop2' , null , true ) ;
79
79
@@ -89,21 +89,25 @@ describe('LiveController query string binding', () => {
89
89
) ;
90
90
91
91
// 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' ) ;
93
95
94
96
await test . component . set ( 'prop' , [ 'foo' , 'bar' ] , true ) ;
95
97
96
98
expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo&prop[1]=bar' ) ;
97
99
98
100
// Remove one value
99
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' ] } ) ;
101
+ test . expectsAjaxCall ( )
102
+ . expectUpdatedData ( { prop : [ 'foo' ] } )
103
+ . willReturnLiveUrl ( '?prop[0]=foo' ) ;
100
104
101
105
await test . component . set ( 'prop' , [ 'foo' ] , true ) ;
102
106
103
107
expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo' ) ;
104
108
105
109
// Remove all remaining values
106
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) ;
110
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) . willReturnLiveUrl ( '?prop=' ) ;
107
111
108
112
await test . component . set ( 'prop' , [ ] , true ) ;
109
113
@@ -119,28 +123,34 @@ describe('LiveController query string binding', () => {
119
123
) ;
120
124
121
125
// Set single nested prop
122
- test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) ;
126
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) . willReturnLiveUrl ( '?prop[foo]=dummy' ) ;
123
127
124
128
await test . component . set ( 'prop.foo' , 'dummy' , true ) ;
125
129
126
130
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=dummy' ) ;
127
131
128
132
// 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' ) ;
130
136
131
137
await test . component . set ( 'prop' , { foo : 'other' , bar : 42 } , true ) ;
132
138
133
139
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other&prop[bar]=42' ) ;
134
140
135
141
// 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' ) ;
137
145
138
146
await test . component . set ( 'prop' , { foo : 'other' , bar : null } , true ) ;
139
147
140
148
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other' ) ;
141
149
142
150
// 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=' ) ;
144
154
145
155
await test . component . set ( 'prop' , { foo : null , bar : null } , true ) ;
146
156
@@ -162,13 +172,15 @@ describe('LiveController query string binding', () => {
162
172
. expectActionCalled ( 'changeProp' )
163
173
. serverWillChangeProps ( ( data : any ) => {
164
174
data . prop = 'foo' ;
165
- } ) ;
175
+ } )
176
+ . willReturnLiveUrl ( '?prop=foo' ) ;
166
177
167
178
getByText ( test . element , 'Change prop' ) . click ( ) ;
168
179
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
+ } ) ;
172
184
} ) ;
173
185
174
186
it ( 'uses custom name instead of prop name in the URL' , async ( ) => {
@@ -180,14 +192,14 @@ describe('LiveController query string binding', () => {
180
192
) ;
181
193
182
194
// Set value
183
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
195
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) . willReturnLiveUrl ( '?alias1=foo' ) ;
184
196
185
197
await test . component . set ( 'prop1' , 'foo' , true ) ;
186
198
187
199
expectCurrentSearch ( ) . toEqual ( '?alias1=foo' ) ;
188
200
189
201
// Remove value
190
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
202
+ test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) . willReturnLiveUrl ( '?alias1=' ) ;
191
203
192
204
await test . component . set ( 'prop1' , '' , true ) ;
193
205
0 commit comments