Skip to content

Commit

Permalink
test(t): verify lazy initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
macarie committed Feb 2, 2024
1 parent 967d45e commit 0232c61
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/t/tests/factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,25 @@ it("uses initial cache", async () => {
expect(await getTranslations("some")).toBe(enUSCached);
});

it("can be lazy initialized", async () => {
const [options, hooks, loaders] = getMocks();

const { init } = createDefineTranslationsConfig(false, options)(
loaders,
{
formatter,
localeSource: ["en-US"],
},
true,
);

expect(hooks.setLocale).toHaveBeenCalledTimes(0);

init(["en-GB"]);

expect(hooks.setLocale).toHaveBeenLastCalledWith("en-GB");
});

describe("`defaultLocale`", () => {
it("calls `locale.setter` when it's a string", () => {
const [options, { setLocale }, loaders] = getMocks();
Expand Down

0 comments on commit 0232c61

Please sign in to comment.