@@ -49,14 +49,18 @@ describe('LiveController query string binding', () => {
49
49
// String
50
50
51
51
// Set value
52
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
52
+ test . expectsAjaxCall ( )
53
+ . expectUpdatedData ( { prop1 : 'foo' } )
54
+ . willReturnLiveUrl ( '?prop1=foo&prop2=' ) ;
53
55
54
56
await test . component . set ( 'prop1' , 'foo' , true ) ;
55
57
56
58
expectCurrentSearch ( ) . toEqual ( '?prop1=foo&prop2=' ) ;
57
59
58
60
// Remove value
59
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
61
+ test . expectsAjaxCall ( )
62
+ . expectUpdatedData ( { prop1 : '' } )
63
+ . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
60
64
61
65
await test . component . set ( 'prop1' , '' , true ) ;
62
66
@@ -65,14 +69,18 @@ describe('LiveController query string binding', () => {
65
69
// Number
66
70
67
71
// Set value
68
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : 42 } ) ;
72
+ test . expectsAjaxCall ( )
73
+ . expectUpdatedData ( { prop2 : 42 } )
74
+ . willReturnLiveUrl ( '?prop1=&prop2=42' ) ;
69
75
70
76
await test . component . set ( 'prop2' , 42 , true ) ;
71
77
72
78
expectCurrentSearch ( ) . toEqual ( '?prop1=&prop2=42' ) ;
73
79
74
80
// Remove value
75
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop2 : null } ) ;
81
+ test . expectsAjaxCall ( )
82
+ . expectUpdatedData ( { prop2 : null } )
83
+ . willReturnLiveUrl ( '?prop1=&prop2=' ) ;
76
84
77
85
await test . component . set ( 'prop2' , null , true ) ;
78
86
@@ -88,21 +96,27 @@ describe('LiveController query string binding', () => {
88
96
) ;
89
97
90
98
// Set value
91
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } ) ;
99
+ test . expectsAjaxCall ( )
100
+ . expectUpdatedData ( { prop : [ 'foo' , 'bar' ] } )
101
+ . willReturnLiveUrl ( '?prop[0]=foo&prop[1]=bar' ) ;
92
102
93
103
await test . component . set ( 'prop' , [ 'foo' , 'bar' ] , true ) ;
94
104
95
105
expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo&prop[1]=bar' ) ;
96
106
97
107
// Remove one value
98
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ 'foo' ] } ) ;
108
+ test . expectsAjaxCall ( )
109
+ . expectUpdatedData ( { prop : [ 'foo' ] } )
110
+ . willReturnLiveUrl ( '?prop[0]=foo' ) ;
99
111
100
112
await test . component . set ( 'prop' , [ 'foo' ] , true ) ;
101
113
102
114
expectCurrentSearch ( ) . toEqual ( '?prop[0]=foo' ) ;
103
115
104
116
// Remove all remaining values
105
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : [ ] } ) ;
117
+ test . expectsAjaxCall ( )
118
+ . expectUpdatedData ( { prop : [ ] } )
119
+ . willReturnLiveUrl ( '?prop=' ) ;
106
120
107
121
await test . component . set ( 'prop' , [ ] , true ) ;
108
122
@@ -118,28 +132,36 @@ describe('LiveController query string binding', () => {
118
132
) ;
119
133
120
134
// Set single nested prop
121
- test . expectsAjaxCall ( ) . expectUpdatedData ( { 'prop.foo' : 'dummy' } ) ;
135
+ test . expectsAjaxCall ( )
136
+ . expectUpdatedData ( { 'prop.foo' : 'dummy' } )
137
+ . willReturnLiveUrl ( '?prop[foo]=dummy' ) ;
122
138
123
139
await test . component . set ( 'prop.foo' , 'dummy' , true ) ;
124
140
125
141
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=dummy' ) ;
126
142
127
143
// Set multiple values
128
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } ) ;
144
+ test . expectsAjaxCall ( )
145
+ . expectUpdatedData ( { prop : { foo : 'other' , bar : 42 } } )
146
+ . willReturnLiveUrl ( '?prop[foo]=other&prop[bar]=42' ) ;
129
147
130
148
await test . component . set ( 'prop' , { foo : 'other' , bar : 42 } , true ) ;
131
149
132
150
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other&prop[bar]=42' ) ;
133
151
134
152
// Remove one value
135
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } ) ;
153
+ test . expectsAjaxCall ( )
154
+ . expectUpdatedData ( { prop : { foo : 'other' , bar : null } } )
155
+ . willReturnLiveUrl ( '?prop[foo]=other' ) ;
136
156
137
157
await test . component . set ( 'prop' , { foo : 'other' , bar : null } , true ) ;
138
158
139
159
expectCurrentSearch ( ) . toEqual ( '?prop[foo]=other' ) ;
140
160
141
161
// Remove all values
142
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop : { foo : null , bar : null } } ) ;
162
+ test . expectsAjaxCall ( )
163
+ . expectUpdatedData ( { prop : { foo : null , bar : null } } )
164
+ . willReturnLiveUrl ( '?prop=' ) ;
143
165
144
166
await test . component . set ( 'prop' , { foo : null , bar : null } , true ) ;
145
167
@@ -161,7 +183,8 @@ describe('LiveController query string binding', () => {
161
183
. expectActionCalled ( 'changeProp' )
162
184
. serverWillChangeProps ( ( data : any ) => {
163
185
data . prop = 'foo' ;
164
- } ) ;
186
+ } )
187
+ . willReturnLiveUrl ( '?prop=foo' ) ;
165
188
166
189
getByText ( test . element , 'Change prop' ) . click ( ) ;
167
190
@@ -179,14 +202,18 @@ describe('LiveController query string binding', () => {
179
202
) ;
180
203
181
204
// Set value
182
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : 'foo' } ) ;
205
+ test . expectsAjaxCall ( )
206
+ . expectUpdatedData ( { prop1 : 'foo' } )
207
+ . willReturnLiveUrl ( '?alias1=foo' ) ;
183
208
184
209
await test . component . set ( 'prop1' , 'foo' , true ) ;
185
210
186
211
expectCurrentSearch ( ) . toEqual ( '?alias1=foo' ) ;
187
212
188
213
// Remove value
189
- test . expectsAjaxCall ( ) . expectUpdatedData ( { prop1 : '' } ) ;
214
+ test . expectsAjaxCall ( )
215
+ . expectUpdatedData ( { prop1 : '' } )
216
+ . willReturnLiveUrl ( '?alias1=' ) ;
190
217
191
218
await test . component . set ( 'prop1' , '' , true ) ;
192
219
0 commit comments