Skip to content

Commit

Permalink
Revert "test: remove unused tsdocs"
Browse files Browse the repository at this point in the history
This reverts commit d2cf531.
  • Loading branch information
lihbr committed Sep 4, 2024
1 parent d2cf531 commit 667699f
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 31 deletions.
14 changes: 12 additions & 2 deletions test/helpers-isFilled.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ it("image", (ctx) => {
expect(isFilled.image(null)).toBe(false)
expect(isFilled.image(undefined)).toBe(false)
expect(isFilled.image({})).toBe(false)
expect(isFilled.image(ctx.mock.value.image())).toBe(true)
expect(
isFilled.image(
// @ts-expect-error Remove this comment after v7.3.0 is published.
ctx.mock.value.image(),
),
).toBe(true)
})

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

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

const actual = await mapSliceZone(sliceZone, {
[model1.id]: () => ({ foo: "bar" }),
[model2.id]: () => ({ baz: "qux" }),
})
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" }),
},
)

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -50,10 +54,14 @@ 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(sliceZone, {
[model1.id]: () => void 0,
[model2.id]: () => void 0,
})
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,
},
)

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id },
Expand All @@ -64,10 +72,14 @@ 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(sliceZone, {
[model1.id]: async () => ({ foo: "bar" }),
[model2.id]: async () => ({ baz: "qux" }),
})
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" }),
},
)

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -78,10 +90,14 @@ 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(sliceZone, {
[model1.id]: async () => ({ id: "foo", slice_type: "bar" }),
[model2.id]: async () => ({ id: "baz", slice_type: "qux" }),
})
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" }),
},
)

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

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

expect(mapper1).toHaveBeenCalledWith({
context: undefined,
Expand All @@ -123,6 +143,7 @@ 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 @@ -148,12 +169,16 @@ it("supports context", async (ctx) => {
it("supports lazy-loaded mapping functions", async (ctx) => {
const { sliceZone, model1, model2 } = generateTestData(ctx)

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" }),
})
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" }),
},
)

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id, foo: "bar" },
Expand All @@ -164,9 +189,13 @@ 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(sliceZone, {
[model1.id]: () => void 0,
})
const actual = await mapSliceZone(
// @ts-expect-error Remove this comment after v7.3.0 is published.
sliceZone,
{
[model1.id]: () => void 0,
},
)

expect(actual).toStrictEqual([
{ __mapped: true, id: undefined, slice_type: model1.id },
Expand Down

0 comments on commit 667699f

Please sign in to comment.