Skip to content

Commit

Permalink
test: add tests for text in links
Browse files Browse the repository at this point in the history
  • Loading branch information
levimykel committed Aug 14, 2024
1 parent 8459d75 commit 577fa7a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/types/customType-contentRelationship.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ expectType<prismic.CustomTypeModelContentRelationshipField<string, "foo">>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelContentRelationshipField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Document,
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
13 changes: 13 additions & 0 deletions test/types/customType-link.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ expectType<prismic.CustomTypeModelLinkField>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelLinkField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
14 changes: 14 additions & 0 deletions test/types/customType-linkToMedia.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ expectType<prismic.CustomTypeModelLinkToMediaField>({
},
})

/**
* Supports optional `text` property.
*/
expectType<prismic.CustomTypeModelLinkToMediaField>({
type: prismic.CustomTypeModelFieldType.Link,
config: {
label: "string",
select: prismic.CustomTypeModelLinkSelectType.Media,
text: {
type: prismic.CustomTypeModelFieldType.Text,
},
},
})

/**
* `@prismicio/types` extends `@prismicio/types-internal`
*/
Expand Down
3 changes: 3 additions & 0 deletions test/types/fields-contentRelationship.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ expectType<prismic.ContentRelationshipField>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
expectType<prismic.ContentRelationshipField<string, string, never, "filled">>({
link_type: prismic.LinkType.Document,
Expand All @@ -44,6 +45,7 @@ expectType<prismic.ContentRelationshipField<string, string, never, "filled">>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
expectType<prismic.ContentRelationshipField<string, string, never, "empty">>({
link_type: prismic.LinkType.Document,
Expand All @@ -57,6 +59,7 @@ expectType<prismic.ContentRelationshipField<string, string, never, "empty">>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})

/**
Expand Down
5 changes: 5 additions & 0 deletions test/types/fields-link.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ expectType<prismic.LinkField>({
link_type: prismic.LinkType.Web,
url: "string",
target: "string",
text: "string",
})
// Content relationship link
expectType<prismic.LinkField>({
Expand All @@ -54,6 +55,7 @@ expectType<prismic.LinkField>({
slug: "string",
isBroken: true,
data: undefined,
text: "string",
})
// Media link
expectType<prismic.LinkField>({
Expand All @@ -64,17 +66,20 @@ expectType<prismic.LinkField>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkField<string, string, never, "filled">>({
link_type: prismic.LinkType.Web,
url: "string",
target: "string",
text: "string",
})
expectType<prismic.LinkField<string, string, never, "empty">>({
link_type: prismic.LinkType.Web,
// @ts-expect-error - Empty fields cannot contain a filled value.
url: "string",
target: "string",
text: "string",
})

/**
Expand Down
3 changes: 3 additions & 0 deletions test/types/fields-linkToMedia.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ expectType<prismic.LinkToMediaField>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkToMediaField<"filled">>({
id: "string",
Expand All @@ -40,6 +41,7 @@ expectType<prismic.LinkToMediaField<"filled">>({
size: "string",
height: "string",
width: "string",
text: "string",
})
expectType<prismic.LinkToMediaField<"empty">>({
link_type: prismic.LinkType.Media,
Expand All @@ -51,6 +53,7 @@ expectType<prismic.LinkToMediaField<"empty">>({
size: "string",
height: "string",
width: "string",
text: "string",
})

/**
Expand Down

0 comments on commit 577fa7a

Please sign in to comment.