Skip to content

Commit 3c93cff

Browse files
committed
fix upload test issue caused by assuming order
1 parent 5836659 commit 3c93cff

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/web/src/utils/__tests__/upload.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ describe('Zod3', () => {
3737
const result = Zod3.getZodTypeName(z3.array(z3.object({ age: z3.number(), name: z3.string() })));
3838
expect(result).toMatchObject({
3939
isOptional: false,
40-
multiKeys: ['name', 'age'],
4140
typeName: 'ZodArray'
4241
});
42+
expect(result.multiKeys).toHaveLength(2);
43+
expect(result.multiKeys).toEqual(expect.arrayContaining(['name', 'age']));
4344
expect(result.multiValues).toHaveLength(2);
44-
expect(result.multiValues?.[0]).toMatchObject({ typeName: 'ZodString' });
45-
expect(result.multiValues?.[1]).toMatchObject({ typeName: 'ZodNumber' });
45+
// Find the index of each key to check the corresponding value
46+
const nameIndex = result.multiKeys?.indexOf('name') ?? -1;
47+
const ageIndex = result.multiKeys?.indexOf('age') ?? -1;
48+
expect(result.multiValues?.[nameIndex]).toMatchObject({ typeName: 'ZodString' });
49+
expect(result.multiValues?.[ageIndex]).toMatchObject({ typeName: 'ZodNumber' });
4650
});
4751

4852
it('should parse set type', () => {

0 commit comments

Comments
 (0)