Skip to content

Commit

Permalink
fix: add missing is_master property on repository type
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Aug 27, 2024
1 parent f94cf80 commit 0289698
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 110 deletions.
44 changes: 5 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/types/api/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export interface Language {
* The name of the language.
*/
name: string

/**
* Whether or not the language is the default language of the repository.
*/
is_master: boolean
}

/**
Expand Down
14 changes: 2 additions & 12 deletions test/helpers-isFilled.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ it("image", (ctx) => {
expect(isFilled.image(null)).toBe(false)
expect(isFilled.image(undefined)).toBe(false)
expect(isFilled.image({})).toBe(false)
expect(
isFilled.image(
// @ts-expect-error Remove this comment after v7.3.0 is published.
ctx.mock.value.image(),
),
).toBe(true)
expect(isFilled.image(ctx.mock.value.image())).toBe(true)
})

it("image thumbnail", () => {
Expand Down Expand Up @@ -137,12 +132,7 @@ it("rich text", (ctx) => {
expect(isFilled.richText([{ type: "paragraph", text: "", spans: [] }])).toBe(
false,
)
expect(
isFilled.richText(
// @ts-expect-error Remove this comment after v7.3.0 is published.
ctx.mock.value.richText(),
),
).toBe(true)
expect(isFilled.richText(ctx.mock.value.richText())).toBe(true)
})

it("select", (ctx) => {
Expand Down
87 changes: 29 additions & 58 deletions test/helpers-mapSliceZone.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ const generateTestData = (ctx: TestContext) => {
it("maps a Slice Zone", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: () => ({ foo: "bar" }),
[model2.id]: () => ({ baz: "qux" }),
},
)
const actual = await mapSliceZone(sliceZone, {
[model1.id]: () => ({ foo: "bar" }),
[model2.id]: () => ({ baz: "qux" }),
})

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -54,14 +50,10 @@ it("maps a Slice Zone", async (ctx) => {
it("supports mapping functions that return undefined", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: () => void 0,
[model2.id]: () => void 0,
},
)
const actual = await mapSliceZone(sliceZone, {
[model1.id]: () => void 0,
[model2.id]: () => void 0,
})

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id },
Expand All @@ -72,14 +64,10 @@ it("supports mapping functions that return undefined", async (ctx) => {
it("supports async mapping functions", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: async () => ({ foo: "bar" }),
[model2.id]: async () => ({ baz: "qux" }),
},
)
const actual = await mapSliceZone(sliceZone, {
[model1.id]: async () => ({ foo: "bar" }),
[model2.id]: async () => ({ baz: "qux" }),
})

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -90,14 +78,10 @@ it("supports async mapping functions", async (ctx) => {
it("supports overriding id and slice_type properties", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: async () => ({ id: "foo", slice_type: "bar" }),
[model2.id]: async () => ({ id: "baz", slice_type: "qux" }),
},
)
const actual = await mapSliceZone(sliceZone, {
[model1.id]: async () => ({ id: "foo", slice_type: "bar" }),
[model2.id]: async () => ({ id: "baz", slice_type: "qux" }),
})

expect(actual).toStrictEqual([
{ __mapped: true, id: "foo", slice_type: "bar" },
Expand All @@ -111,14 +95,10 @@ it("provides Slice data to mapping functions", async (ctx) => {
const mapper1 = vi.fn()
const mapper2 = vi.fn()

await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: mapper1,
[model2.id]: mapper2,
},
)
await mapSliceZone(sliceZone, {
[model1.id]: mapper1,
[model2.id]: mapper2,
})

expect(mapper1).toHaveBeenCalledWith({
context: undefined,
Expand All @@ -143,7 +123,6 @@ it("supports context", async (ctx) => {
const context = { foo: "bar" }

await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: mapper1,
Expand All @@ -169,16 +148,12 @@ it("supports context", async (ctx) => {
it("supports lazy-loaded mapping functions", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
// Simulates `import()` with a named `default` export.
[model1.id]: async () => ({ default: () => ({ foo: "bar" }) }),
// Simulates `import()` with a default export.
[model2.id]: async () => () => ({ baz: "qux" }),
},
)
const actual = await mapSliceZone(sliceZone, {
// Simulates `import()` with a named `default` export.
[model1.id]: async () => ({ default: () => ({ foo: "bar" }) }),
// Simulates `import()` with a default export.
[model2.id]: async () => () => ({ baz: "qux" }),
})

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -189,13 +164,9 @@ it("supports lazy-loaded mapping functions", async (ctx) => {
it("skips Slices without a mapping function", async (ctx) => {
const { sliceZone, model1 } = generateTestData(ctx)

const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: () => void 0,
},
)
const actual = await mapSliceZone(sliceZone, {
[model1.id]: () => void 0,
})

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id },
Expand Down
1 change: 1 addition & 0 deletions test/types/api-language.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ import type * as prismic from "../../src"
expectType<prismic.Language>({
id: "string",
name: "string",
is_master: true,
})
2 changes: 1 addition & 1 deletion test/types/api-repository.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ expectType<prismic.Repository>({
},
],
integrationFieldsRef: "string",
languages: [{ id: "string", name: "string" }],
languages: [{ id: "string", name: "string", is_master: true }],
types: { foo: "string" },
tags: ["string"],
forms: {
Expand Down

0 comments on commit 0289698

Please sign in to comment.