Skip to content

Commit

Permalink
chore(): create test utils and update index layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Limerio committed Mar 24, 2024
1 parent 44526e3 commit b97b27b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/layouts/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from "./Error"
export * from "./Head"
export * from "./header"
export * from "./Loading"
export * from "./Logo"
export * from "./header"
export * from "./providers"
27 changes: 27 additions & 0 deletions src/utils/test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { pick } from "@/utils/functions"
import { cleanup, render } from "@testing-library/react"
import { NextIntlClientProvider } from "next-intl"
import { afterEach } from "vitest"

afterEach(() => {
cleanup()
})

const customRender = async (ui, { locale, ...options } = { locale: "en" }) => {
const messages = await import(`@/languages/${locale}.json`)

return render(ui, {
wrapper: ({ children }) => (
<NextIntlClientProvider
locale={locale}
messages={pick(messages, children.type.messages || [])}
>
{children}
</NextIntlClientProvider>
),
...options,
})
}

export * from "@testing-library/react"
export { customRender as render }

0 comments on commit b97b27b

Please sign in to comment.