Skip to content

Commit

Permalink
fix: (lingui/core) i18n error if id is undefined - test case added
Browse files Browse the repository at this point in the history
  • Loading branch information
abdul-kissflow committed May 22, 2024
1 parent b28d7ea commit c50207e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/core/src/i18n.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,25 @@ describe("I18n", () => {
expect(handler).toHaveBeenCalledTimes(2)
})

it("._ should emit missing event for undefined id", () => {
const i18n = setupI18n({
locale: "en",
messages: { en: {} },
})

const messageID = undefined

const handler = jest.fn()
i18n.on("missing", handler)
// @ts-ignore
i18n._(messageID)
expect(handler).toHaveBeenCalledTimes(1)
expect(handler).toHaveBeenCalledWith({
id: undefined,
locale: "en",
})
})

describe("params.missing - handling missing translations", () => {
it("._ should return custom string for missing translations", () => {
const i18n = setupI18n({
Expand Down

0 comments on commit c50207e

Please sign in to comment.