Skip to content

Commit 0050cdd

Browse files
Address PR comments
1 parent 508d763 commit 0050cdd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/snaps-sdk/src/internals/structs.test.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,6 @@ describe('typedUnion', () => {
6969
BoxStruct,
7070
typedUnion([TextStruct, FieldStruct]),
7171
]);
72-
const stringUnion = nullUnion([
73-
string(),
74-
typedUnion([TextStruct, BoldStruct]),
75-
]);
76-
const nonTypedObjectUnion = nullUnion([
77-
typedUnion([TextStruct, BoldStruct]),
78-
object({ type: literal('bar') }),
79-
]);
8072

8173
it('validates strictly the part of the union that matches the type', () => {
8274
// @ts-expect-error Invalid props.
@@ -97,6 +89,11 @@ describe('typedUnion', () => {
9789
});
9890

9991
it('validates when nested in a union including primitives', () => {
92+
const stringUnion = nullUnion([
93+
string(),
94+
typedUnion([TextStruct, BoldStruct]),
95+
]);
96+
10097
// @ts-expect-error Invalid props.
10198
const result = validate(Text({}), stringUnion);
10299

@@ -106,6 +103,11 @@ describe('typedUnion', () => {
106103
});
107104

108105
it('validates when nested in a union including non-typed objects', () => {
106+
const nonTypedObjectUnion = nullUnion([
107+
typedUnion([TextStruct, BoldStruct]),
108+
object({ type: literal('bar') }),
109+
]);
110+
109111
const result = validate({ type: 'abc' }, nonTypedObjectUnion);
110112

111113
expect(result[0]?.message).toBe(

packages/snaps-sdk/src/jsx/validation.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export const BoldStruct: Describe<BoldElement> = element('Bold', {
620620
return string();
621621
}
622622
// eslint-disable-next-line @typescript-eslint/no-use-before-define
623-
return lazy(() => ItalicStruct) as unknown as Struct<
623+
return ItalicStruct as unknown as Struct<
624624
SnapElement<JsonObject, 'Italic'>
625625
>;
626626
}),
@@ -637,9 +637,7 @@ export const ItalicStruct: Describe<ItalicElement> = element('Italic', {
637637
return string();
638638
}
639639

640-
return lazy(() => BoldStruct) as unknown as Struct<
641-
SnapElement<JsonObject, 'Bold'>
642-
>;
640+
return BoldStruct as unknown as Struct<SnapElement<JsonObject, 'Bold'>>;
643641
}),
644642
]),
645643
});

0 commit comments

Comments
 (0)