From dfc0558df0746e6a8fcd847b1d646136f12c31ab Mon Sep 17 00:00:00 2001 From: lihbr Date: Fri, 9 Jun 2023 14:07:39 +0200 Subject: [PATCH] fix: use config object serializer properly with `asHTML` --- src/createPrismic.ts | 2 +- test/createPrismic-helpers.test.ts | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/createPrismic.ts b/src/createPrismic.ts index a8d670e..9107fee 100644 --- a/src/createPrismic.ts +++ b/src/createPrismic.ts @@ -91,7 +91,7 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => { : { linkResolver: options.linkResolver, serializer: options.richTextSerializer || options.htmlSerializer, - ...config, + ...configOrLinkResolver, }, ); }, diff --git a/test/createPrismic-helpers.test.ts b/test/createPrismic-helpers.test.ts index 82502c7..7cb8281 100644 --- a/test/createPrismic-helpers.test.ts +++ b/test/createPrismic-helpers.test.ts @@ -88,7 +88,31 @@ it("`asHTML` uses provided default deprecated serializer", () => { expect(spiedRichTextSerializer).toHaveBeenCalled(); }); -it("`asHTML` uses provided HTML serializer over default provided", () => { +it("`asHTML` uses provided serializer over default provided", () => { + const spiedRichTextSerializer1 = vi.fn(); + const spiedRichTextSerializer2 = vi.fn(); + + const prismic = createPrismic({ + endpoint: "test", + richTextSerializer: spiedRichTextSerializer1, + }); + + const wrapper = mount(WrapperComponent, { + global: { + plugins: [prismic], + }, + }); + + wrapper.vm.$prismic.asHTML(richTextFixture.en, { + serializer: spiedRichTextSerializer2, + }); + + expect(spiedRichTextSerializer1).not.toHaveBeenCalled(); + expect(spiedRichTextSerializer2).toHaveBeenCalled(); +}); + +// TODO: Remove in v5 +it("`asHTML` uses provided deprecated serializer over default provided", () => { const spiedRichTextSerializer1 = vi.fn(); const spiedRichTextSerializer2 = vi.fn();