Lorem ipsum dolor sit amet.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- - -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- - -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- - -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- -fallback
") + expect(undefinedField.html()).toBe("fallback
") + expect(emptyField.html()).toBe("fallback
") }) - - expect(wrapper.html()).toMatchSnapshot() }) -it("uses plugin provided link resolver", (ctx) => { - const spiedLinkResolver = vi.fn(() => ctx.task.name) +describe("renders with wrapper", () => { + it("tag", () => { + const wrapper = mount(PrismicRichText, { + props: { + field: [ + { + type: RichTextNodeType.heading1, + text: "Heading 1", + spans: [], + }, + ], + wrapper: "section", + }, + }) - const prismic = createPrismic({ - endpoint: "test", - linkResolver: spiedLinkResolver, + expect(wrapper.html()).toBe(`${ctx.task.name}
` : null, - ) + const wrapper = mount(PrismicRichText, { + props: { field: richTextFixture.en }, + global: { plugins: [prismic] }, + }) - const prismic = createPrismic({ - endpoint: "test", - richTextSerializer: spiedSerializer, + expect(spiedLinkResolver).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`href="${ctx.task.name}"`) }) - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - }, - global: { plugins: [prismic] }, - }) + it("from props (priority over plugin)", (ctx) => { + const spiedLinkResolver1 = vi.fn(() => `${ctx.task.name}1`) + const spiedLinkResolver2 = vi.fn(() => `${ctx.task.name}2`) - expect(spiedSerializer).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}
`) -}) + const prismic = createPrismic({ + endpoint: "test", + linkResolver: spiedLinkResolver1, + }) -it("uses provided HTML function serializer over plugin provided", (ctx) => { - const spiedSerializer1 = vi.fn((type: RichTextNodeTypes) => - type === RichTextNodeType.paragraph ? `${ctx.task.name}1
` : null, - ) - const spiedSerializer2 = vi.fn((type: RichTextNodeTypes) => - type === RichTextNodeType.paragraph ? `${ctx.task.name}2
` : null, - ) + const wrapper = mount(PrismicRichText, { + props: { field: richTextFixture.en, linkResolver: spiedLinkResolver2 }, + global: { plugins: [prismic] }, + }) - const prismic = createPrismic({ - endpoint: "test", - richTextSerializer: spiedSerializer1, + expect(spiedLinkResolver1).not.toHaveBeenCalled() + expect(spiedLinkResolver2).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`href="${ctx.task.name}2"`) }) +}) - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - serializer: spiedSerializer2, - }, - global: { plugins: [prismic] }, - }) +// TODO: Remove in v6 +describe("uses HTML serializer", () => { + it("function from plugin", (ctx) => { + const spiedSerializer = vi.fn((type: RichTextNodeTypes) => + type === RichTextNodeType.paragraph ? `${ctx.task.name}
` : null, + ) - expect(spiedSerializer1).not.toHaveBeenCalled() - expect(spiedSerializer2).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}2
`) -}) + const prismic = createPrismic({ + endpoint: "test", + richTextSerializer: spiedSerializer, + }) -it("uses plugin provided HTML map serializer", (ctx) => { - const spiedSerializer = { - paragraph: vi.fn(() => `${ctx.task.name}
`), - } + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.en, + }, + global: { plugins: [prismic] }, + }) - const prismic = createPrismic({ - endpoint: "test", - richTextSerializer: spiedSerializer, + expect(spiedSerializer).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`${ctx.task.name}
`) }) - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - }, - global: { plugins: [prismic] }, - }) + it("map from plugin", (ctx) => { + const spiedSerializer = { + paragraph: vi.fn(() => `${ctx.task.name}
`), + } - expect(spiedSerializer.paragraph).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}
`) -}) + const prismic = createPrismic({ + endpoint: "test", + richTextSerializer: spiedSerializer, + }) -it("uses provided HTML map serializer over plugin provided", (ctx) => { - const spiedSerializer1 = { - paragraph: vi.fn(() => `${ctx.task.name}1
`), - } - const spiedSerializer2 = { - paragraph: vi.fn(() => `${ctx.task.name}2
`), - } - - const prismic = createPrismic({ - endpoint: "test", - richTextSerializer: spiedSerializer1, - }) + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.en, + }, + global: { plugins: [prismic] }, + }) - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - serializer: spiedSerializer2, - }, - global: { plugins: [prismic] }, + expect(spiedSerializer.paragraph).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`${ctx.task.name}
`) }) - expect(spiedSerializer1.paragraph).not.toHaveBeenCalled() - expect(spiedSerializer2.paragraph).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}2
`) -}) + it("function from props (priority over plugin)", (ctx) => { + const spiedSerializer1 = vi.fn((type: RichTextNodeTypes) => + type === RichTextNodeType.paragraph ? `${ctx.task.name}1
` : null, + ) + const spiedSerializer2 = vi.fn((type: RichTextNodeTypes) => + type === RichTextNodeType.paragraph ? `${ctx.task.name}2
` : null, + ) + + const prismic = createPrismic({ + endpoint: "test", + richTextSerializer: spiedSerializer1, + }) -// TODO: Remove in v5 -it("uses plugin provided deprecated HTML serializer", (ctx) => { - const spiedSerializer = { - paragraph: vi.fn(() => `${ctx.task.name}
`), - } + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.en, + serializer: spiedSerializer2, + }, + global: { plugins: [prismic] }, + }) - const prismic = createPrismic({ - endpoint: "test", - htmlSerializer: spiedSerializer, + expect(spiedSerializer1).not.toHaveBeenCalled() + expect(spiedSerializer2).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`${ctx.task.name}2
`) }) - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - }, - global: { plugins: [prismic] }, - }) + it("map from props (priority over plugin)", (ctx) => { + const spiedSerializer1 = { + paragraph: vi.fn(() => `${ctx.task.name}1
`), + } + const spiedSerializer2 = { + paragraph: vi.fn(() => `${ctx.task.name}2
`), + } + + const prismic = createPrismic({ + endpoint: "test", + richTextSerializer: spiedSerializer1, + }) - expect(spiedSerializer.paragraph).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}
`) -}) + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.en, + serializer: spiedSerializer2, + }, + global: { plugins: [prismic] }, + }) -// TODO: Remove in v5 -it("uses provided deprecated HTML serializer over plugin provided", (ctx) => { - const spiedSerializer1 = { - paragraph: vi.fn(() => `${ctx.task.name}1
`), - } - const spiedSerializer2 = { - paragraph: vi.fn(() => `${ctx.task.name}2
`), - } - - const prismic = createPrismic({ - endpoint: "test", - richTextSerializer: spiedSerializer1, + expect(spiedSerializer1.paragraph).not.toHaveBeenCalled() + expect(spiedSerializer2.paragraph).toHaveBeenCalled() + expect(wrapper.html()).toMatch(`${ctx.task.name}2
`) }) - - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.en, - htmlSerializer: spiedSerializer2, - }, - global: { plugins: [prismic] }, - }) - - expect(spiedSerializer1.paragraph).not.toHaveBeenCalled() - expect(spiedSerializer2.paragraph).toHaveBeenCalled() - expect(wrapper.html()).toMatch(`${ctx.task.name}2
`) }) -it("navigates internal links using Vue Router if available on click", async () => { - const spiedPush = vi.fn() +// TODO: Remove in v6 +describe("navigates internal links using Vue Router if available", () => { + it("on click", async () => { + const spiedPush = vi.fn() - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.link, - serializer: { - hyperlink: () => `link`, + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.link, + serializer: { + hyperlink: () => `link`, + }, }, - }, - global: { - provide: { - [routerKey as unknown as string]: { - push: spiedPush, + global: { + provide: { + [routerKey as unknown as string]: { + push: spiedPush, + }, }, }, - }, - }) + }) - // Click doesn't propagate if we don't wait here - await flushPromises() + // Click doesn't propagate if we don't wait here + await flushPromises() - await wrapper.get("a").trigger("click") + await wrapper.get("a").trigger("click") - expect(spiedPush).toHaveBeenCalledOnce() - expect(spiedPush).toHaveBeenCalledWith(`/foo`) + expect(spiedPush).toHaveBeenCalledOnce() + expect(spiedPush).toHaveBeenCalledWith(`/foo`) - // This is used to make sure `removeListeners()` is called upon unmount - wrapper.unmount() -}) + // This is used to make sure `removeListeners()` is called upon unmount + wrapper.unmount() + }) -it("navigates internal links using Vue Router if available on click when using custom wrapper", async () => { - const spiedPush = vi.fn() + it("on click when using custom wrapper", async () => { + const spiedPush = vi.fn() - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.link, - wrapper: markRaw(WrapperComponent), - serializer: { - hyperlink: () => `link`, + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.link, + wrapper: markRaw(WrapperComponent), + serializer: { + hyperlink: () => `link`, + }, }, - }, - global: { - provide: { - [routerKey as unknown as string]: { - push: spiedPush, + global: { + provide: { + [routerKey as unknown as string]: { + push: spiedPush, + }, }, }, - }, - }) + }) - // Click doesn't propagate if we don't wait here - await flushPromises() + // Click doesn't propagate if we don't wait here + await flushPromises() - await wrapper.get("a").trigger("click") + await wrapper.get("a").trigger("click") - expect(spiedPush).toHaveBeenCalledOnce() - expect(spiedPush).toHaveBeenCalledWith(`/foo`) -}) + expect(spiedPush).toHaveBeenCalledOnce() + expect(spiedPush).toHaveBeenCalledWith(`/foo`) + }) -it("navigates internal links using Vue Router if available on inner tag click", async () => { - const spiedPush = vi.fn() + it("on inner tag click", async () => { + const spiedPush = vi.fn() - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.link, - serializer: { - hyperlink: () => `link`, + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.link, + serializer: { + hyperlink: () => `link`, + }, }, - }, - global: { - provide: { - [routerKey as unknown as string]: { - push: spiedPush, + global: { + provide: { + [routerKey as unknown as string]: { + push: spiedPush, + }, }, }, - }, - }) + }) - // Click doesn't propagate if we don't wait here - await flushPromises() + // Click doesn't propagate if we don't wait here + await flushPromises() - await wrapper.get("a em").trigger("click") + await wrapper.get("a em").trigger("click") - expect(spiedPush).toHaveBeenCalledOnce() - expect(spiedPush).toHaveBeenCalledWith(`/foo`) -}) + expect(spiedPush).toHaveBeenCalledOnce() + expect(spiedPush).toHaveBeenCalledWith(`/foo`) + }) -it("navigates internal links using Vue Router if available on deep inner tag click", async () => { - const spiedPush = vi.fn() + it("on deep inner tag click", async () => { + const spiedPush = vi.fn() - const wrapper = mount(PrismicRichTextImpl, { - props: { - field: richTextFixture.link, - serializer: { - hyperlink: () => - `link`, + const wrapper = mount(PrismicRichText, { + props: { + field: richTextFixture.link, + serializer: { + hyperlink: () => + `link`, + }, }, - }, - global: { - provide: { - [routerKey as unknown as string]: { - push: spiedPush, + global: { + provide: { + [routerKey as unknown as string]: { + push: spiedPush, + }, }, }, - }, - }) + }) - // Click doesn't propagate if we don't wait here - await flushPromises() + // Click doesn't propagate if we don't wait here + await flushPromises() - await wrapper.get("a em").trigger("click") + await wrapper.get("a em").trigger("click") - expect(spiedPush).toHaveBeenCalledOnce() - expect(spiedPush).toHaveBeenCalledWith(`/foo`) + expect(spiedPush).toHaveBeenCalledOnce() + expect(spiedPush).toHaveBeenCalledWith(`/foo`) + }) }) it("doesn't navigate external links using Vue Router if available on click (navigation error is expected)", async () => { const spiedPush = vi.fn() - const wrapper = mount(PrismicRichTextImpl, { + const wrapper = mount(PrismicRichText, { props: { field: richTextFixture.link, serializer: { @@ -394,7 +435,7 @@ it("doesn't try to bind on click events when Vue Router is available when render await expect(async () => { const spiedPush = vi.fn() - mount(PrismicRichTextImpl, { + mount(PrismicRichText, { props: { field: richTextFixture.link, wrapper: markRaw(() => null), @@ -417,7 +458,7 @@ it("doesn't try to bind on click events when Vue Router is available when render }) it("reacts to changes properly", async () => { - const wrapper = mount(PrismicRichTextImpl, { + const wrapper = mount(PrismicRichText, { props: { field: richTextFixture.en }, }) diff --git a/test/components-PrismicText.test.ts b/test/components-PrismicText.test.ts index 0bf4a2b..f488be3 100644 --- a/test/components-PrismicText.test.ts +++ b/test/components-PrismicText.test.ts @@ -27,7 +27,7 @@ describe("renders a rich text field", () => { it("as nothing when passed an empty field", () => { const wrapper = mount(PrismicText, { - props: { field: null }, + props: { field: [] }, }) expect(wrapper.html()).toBe("") diff --git a/test/createPrismic-helpers.test.ts b/test/createPrismic-helpers.test.ts index 1a315c1..6c840f6 100644 --- a/test/createPrismic-helpers.test.ts +++ b/test/createPrismic-helpers.test.ts @@ -68,49 +68,6 @@ it("`asHTML` uses provided default serializer", () => { expect(spiedRichTextSerializer).toHaveBeenCalled() }) -// TODO: Remove in v5, we prefer `richTextSerializer` now -it("`asHTML` uses provided default deprecated serializer", () => { - const spiedRichTextSerializer = vi.fn() - - const prismic = createPrismic({ - endpoint: "test", - htmlSerializer: spiedRichTextSerializer, - }) - - const wrapper = mount(WrapperComponent, { - global: { - plugins: [prismic], - }, - }) - - wrapper.vm.$prismic.asHTML(richTextFixture.en) - - expect(spiedRichTextSerializer).toHaveBeenCalled() -}) - -// TODO: Remove in v5, we prefer `richTextSerializer` now -it("`asHTML` uses provided serializer over default deprecated serializer", () => { - const spiedRichTextSerializer1 = vi.fn() - const spiedRichTextSerializer2 = vi.fn() - - const prismic = createPrismic({ - endpoint: "test", - htmlSerializer: spiedRichTextSerializer1, - }) - - const wrapper = mount(WrapperComponent, { - global: { - plugins: [prismic], - }, - }) - - wrapper.vm.$prismic.asHTML(richTextFixture.en, { - serializer: spiedRichTextSerializer2, - }) - - expect(spiedRichTextSerializer2).toHaveBeenCalled() -}) - it("`asHTML` uses provided serializer over default provided", () => { const spiedRichTextSerializer1 = vi.fn() const spiedRichTextSerializer2 = vi.fn()