@@ -162,27 +162,27 @@ describe('transformWeightedFields', () => {
162162 test ( 'converts variant:weight arrays to objects' , ( ) => {
163163 const query = { eyesVariant : [ 'happy:3' , 'wink:1' ] } ;
164164 transformWeightedFields ( query , weighted ) ;
165- assert . deepEqual ( query . eyesVariant , { happy : 3 , wink : 1 } ) ;
165+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 3 , wink : 1 } ) ) ;
166166 } ) ;
167167
168168 test ( 'weight is 0 when empty after colon' , ( ) => {
169169 // 'happy:'.split(':') → ['happy', ''], Number('') → 0
170170 const query = { eyesVariant : [ 'happy:' , 'wink:2' ] } ;
171171 transformWeightedFields ( query , weighted ) ;
172- assert . deepEqual ( query . eyesVariant , { happy : 0 , wink : 2 } ) ;
172+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 0 , wink : 2 } ) ) ;
173173 } ) ;
174174
175175 test ( 'defaults weight to 1 when no colon' , ( ) => {
176176 const query = { eyesVariant : [ 'happy:1' , 'wink' ] } ;
177177 transformWeightedFields ( query , weighted ) ;
178- assert . deepEqual ( query . eyesVariant , { happy : 1 , wink : 1 } ) ;
178+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 1 , wink : 1 } ) ) ;
179179 } ) ;
180180
181181 test ( 'leaves non-weighted fields unchanged' , ( ) => {
182182 const query = { size : [ '128' ] , eyesVariant : [ 'happy:2' , 'wink:1' ] } ;
183183 transformWeightedFields ( query , weighted ) ;
184184 assert . deepEqual ( query . size , [ '128' ] ) ;
185- assert . deepEqual ( query . eyesVariant , { happy : 2 , wink : 1 } ) ;
185+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 2 , wink : 1 } ) ) ;
186186 } ) ;
187187
188188 test ( 'leaves arrays without colons unchanged for weighted fields' , ( ) => {
@@ -218,7 +218,7 @@ describe('transformWeightedFields', () => {
218218 test ( 'trims whitespace from variant names' , ( ) => {
219219 const query = { eyesVariant : [ ' happy :2' , ' wink :1' ] } ;
220220 transformWeightedFields ( query , weighted ) ;
221- assert . deepEqual ( query . eyesVariant , { happy : 2 , wink : 1 } ) ;
221+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 2 , wink : 1 } ) ) ;
222222 } ) ;
223223
224224 test ( 'handles multiple weighted fields' , ( ) => {
@@ -227,13 +227,13 @@ describe('transformWeightedFields', () => {
227227 mouthVariant : [ 'smile:2' , 'frown:1' ] ,
228228 } ;
229229 transformWeightedFields ( query , weighted ) ;
230- assert . deepEqual ( query . eyesVariant , { happy : 3 , wink : 1 } ) ;
231- assert . deepEqual ( query . mouthVariant , { smile : 2 , frown : 1 } ) ;
230+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 3 , wink : 1 } ) ) ;
231+ assert . deepEqual ( query . mouthVariant , expected ( { smile : 2 , frown : 1 } ) ) ;
232232 } ) ;
233233
234234 test ( 'detects weighted format when at least one element has colon' , ( ) => {
235235 const query = { eyesVariant : [ 'happy' , 'wink:2' ] } ;
236236 transformWeightedFields ( query , weighted ) ;
237- assert . deepEqual ( query . eyesVariant , { happy : 1 , wink : 2 } ) ;
237+ assert . deepEqual ( query . eyesVariant , expected ( { happy : 1 , wink : 2 } ) ) ;
238238 } ) ;
239239} ) ;
0 commit comments