Skip to content

Commit

Permalink
fix: use config object serializer properly with asHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jun 9, 2023
1 parent 4dcab6c commit dfc0558
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/createPrismic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {
: {
linkResolver: options.linkResolver,
serializer: options.richTextSerializer || options.htmlSerializer,
...config,
...configOrLinkResolver,
},
);
},
Expand Down
26 changes: 25 additions & 1 deletion test/createPrismic-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit dfc0558

Please sign in to comment.