@@ -122,10 +122,10 @@ describe("shuffleArray", () => {
122122describe ( "randomizeArrayWithFixedElements" , ( ) => {
123123 it ( "returns an array of the same length as the input" , ( ) => {
124124 const input = [
125- [ "A" , 0 , false ] ,
126- [ "B" , 1 , true ] ,
127- [ "C" , 2 , false ] ,
128- [ "D" , 3 , true ] ,
125+ { text : "A" , link : "url0" , isRandom : false } ,
126+ { text : "B" , link : "url1" , isRandom : true } ,
127+ { text : "C" , link : "url2" , isRandom : false } ,
128+ { text : "D" , link : "url3" , isRandom : true } ,
129129 ] ;
130130
131131 const result = randomizeArrayWithFixedElements ( [ ...input ] ) ;
@@ -134,10 +134,10 @@ describe("randomizeArrayWithFixedElements", () => {
134134
135135 it ( "keeps fixed elements in their original positions" , ( ) => {
136136 const input = [
137- [ "A" , 0 , false ] ,
138- [ "B" , 1 , true ] ,
139- [ "C" , 2 , false ] ,
140- [ "D" , 3 , true ] ,
137+ { text : "A" , link : "url0" , isRandom : false } ,
138+ { text : "B" , link : "url1" , isRandom : true } ,
139+ { text : "C" , link : "url2" , isRandom : false } ,
140+ { text : "D" , link : "url3" , isRandom : true } ,
141141 ] ;
142142
143143 const result = randomizeArrayWithFixedElements ( [ ...input ] ) ;
@@ -147,10 +147,10 @@ describe("randomizeArrayWithFixedElements", () => {
147147
148148 it ( "preserves the set of randomizable elements but in different order" , ( ) => {
149149 const input = [
150- [ "X" , 0 , false ] ,
151- [ "Y" , 1 , true ] ,
152- [ "Z" , 2 , true ] ,
153- [ "W" , 3 , false ] ,
150+ { text : "X" , link : "url0" , isRandom : false } ,
151+ { text : "Y" , link : "url1" , isRandom : true } ,
152+ { text : "Z" , link : "url2" , isRandom : true } ,
153+ { text : "W" , link : "url3" , isRandom : false } ,
154154 ] ;
155155
156156 const originalRandomizables = input . filter ( ( el ) => el [ 2 ] ) ;
@@ -162,9 +162,9 @@ describe("randomizeArrayWithFixedElements", () => {
162162
163163 it ( "handles an array with only fixed elements" , ( ) => {
164164 const input = [
165- [ "L" , 0 , false ] ,
166- [ "M" , 1 , false ] ,
167- [ "N" , 2 , false ] ,
165+ { text : "L" , link : "url0" , isRandom : false } ,
166+ { text : "M" , link : "url1" , isRandom : false } ,
167+ { text : "N" , link : "url2" , isRandom : false } ,
168168 ] ;
169169
170170 const result = randomizeArrayWithFixedElements ( [ ...input ] ) ;
@@ -173,13 +173,13 @@ describe("randomizeArrayWithFixedElements", () => {
173173
174174 it ( "produces different random arrangements across multiple calls" , ( ) => {
175175 const input = [
176- [ "A" , 0 , false ] ,
177- [ "B" , 1 , true ] ,
178- [ "C" , 2 , true ] ,
179- [ "D" , 3 , true ] ,
180- [ "E" , 4 , false ] ,
181- [ "F" , 4 , true ] ,
182- [ "G" , 4 , true ] ,
176+ { text : "A" , link : "url0" , isRandom : false } ,
177+ { text : "B" , link : "url1" , isRandom : true } ,
178+ { text : "C" , link : "url2" , isRandom : true } ,
179+ { text : "D" , link : "url3" , isRandom : true } ,
180+ { text : "E" , link : "url4" , isRandom : false } ,
181+ { text : "F" , link : "url4" , isRandom : true } ,
182+ { text : "G" , link : "url4" , isRandom : true } ,
183183 ] ;
184184
185185 const arrangements = new Set ( ) ;
@@ -195,7 +195,7 @@ describe("randomizeArrayWithFixedElements", () => {
195195 result [ 5 ] ,
196196 result [ 6 ] ,
197197 ]
198- . map ( ( el ) => el [ 0 ] ) // use element name for comparison
198+ . map ( ( el ) => el . text ) // use element name for comparison
199199 . join ( "," ) ;
200200
201201 arrangements . add ( randomizedPart ) ;
@@ -209,9 +209,9 @@ describe("randomizeArrayWithFixedElements", () => {
209209describe ( "shouldBeRandomized" , ( ) => {
210210 it ( "returns true if at least one element has true as the third value" , ( ) => {
211211 const input = [
212- [ "Option A" , 0 , false ] ,
213- [ "Option B" , 1 , true ] ,
214- [ "Option C" , 2 , false ] ,
212+ { text : "Option A" , link : "url0" , isRandom : false } ,
213+ { text : "Option B" , link : "url1" , isRandom : true } ,
214+ { text : "Option C" , link : "url2" , isRandom : false } ,
215215 ] ;
216216 const result = shouldBeRandomized ( input ) ;
217217 expect ( result ) . toBeTrue ( ) ;
0 commit comments