Skip to content

Commit 5fd929b

Browse files
committed
Add test with block
1 parent fc09028 commit 5fd929b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/optimizely-cms-sdk/src/graph/__test__/createQuery.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,36 @@ describe('createFragment() empty objects', () => {
553553
`);
554554
});
555555
});
556+
557+
describe('createFragment() with component properties', () => {
558+
test('simple case', async () => {
559+
const ctBlock = contentType({
560+
key: 'ctBlock',
561+
baseType: '_component',
562+
properties: {
563+
p1: { type: 'string' },
564+
},
565+
});
566+
const ct1 = contentType({
567+
key: 'ct1',
568+
baseType: '_page',
569+
properties: {
570+
p1: { type: 'component', contentType: ctBlock },
571+
},
572+
});
573+
initContentTypeRegistry([ct1, ctBlock]);
574+
const result = await createFragment('ct1');
575+
expect(result).toMatchInlineSnapshot(`
576+
[
577+
"fragment MediaMetadata on MediaMetadata { mimeType thumbnail content }",
578+
"fragment ItemMetadata on ItemMetadata { changeset displayOption }",
579+
"fragment InstanceMetadata on InstanceMetadata { changeset locales expired container owner routeSegment lastModifiedBy path createdBy }",
580+
"fragment ContentUrl on ContentUrl { type default hierarchical internal graph base }",
581+
"fragment IContentMetadata on IContentMetadata { key locale fallbackForLocale version displayName url {...ContentUrl} types published status created lastModified sortOrder variation ...MediaMetadata ...ItemMetadata ...InstanceMetadata }",
582+
"fragment _IContent on _IContent { _id _metadata {...IContentMetadata} }",
583+
"fragment ctBlockProperty on ctBlockProperty { __typename ctBlock__p1:p1 }",
584+
"fragment ct1 on ct1 { __typename ct1__p1:p1 { ...ctBlockProperty } ..._IContent }",
585+
]
586+
`);
587+
});
588+
});

0 commit comments

Comments
 (0)