Skip to content

Commit

Permalink
chore: u
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Dec 18, 2023
1 parent 24a98a9 commit f97549c
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/react-components/tests/translations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,15 @@
import { expect, test as base } from "@playwright/experimental-ct-react"
import * as supportedLanguages from "../../locales"

type Language = {
[K in keyof typeof supportedLanguages.en]: string
}

type SupportedLanguages = {
[k in keyof typeof supportedLanguages]: Language
}

type TemplateStrings = {
[k in keyof typeof supportedLanguages.en]: string[]
}

const test = base.extend<{
en: Language
translations: SupportedLanguages
templates: Partial<TemplateStrings>
}>({
en: async ({}, use) => {
await use(supportedLanguages.en)
},
translations: async ({}, use) => {
await use(supportedLanguages)
},
templates: async ({ en }, use) => {
templates: async ({}, use) => {
const en = supportedLanguages.en
const templates: Partial<TemplateStrings> = {}
for (const [key, value] of Object.entries(en)) {
const matches = value.match(/\{.+?}/g)
Expand All @@ -40,11 +25,14 @@ const test = base.extend<{
},
})

test("language keys and templates match", async ({
en,
translations,
templates,
}) => {
test("language keys and templates match", async ({ templates }) => {
const translations = supportedLanguages
const en = supportedLanguages.en
console.log("XXXXXXXXXX")
console.log(en)
console.log("XXXXXXXXXX")
console.log(translations)
console.log("XXXXXXXXXX")
await test.step("Checking language keys", () => {
for (const translation of Object.values(translations)) {
expect(Object.keys(translation).sort()).toEqual(Object.keys(en).sort())
Expand Down

0 comments on commit f97549c

Please sign in to comment.