Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✨ feat: add locale unit test #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
cexbrayat merged 5 commits into vuejs:main from CoolPlayLin:vitest/locale
Dec 1, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions __test__/locale.spec.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest'
import { resolve } from 'node:path'
import { readdirSync } from 'node:fs'
import en from '../locales/en-US.json'

function getKeys(obj: any, path = '', result: string[] = []) {
for (let key in obj) {
if (typeof obj[key] === 'object') {
getKeys(obj[key], path ? `${path}.${key}` : key, result);
} else {
result.push(path ? `${path}.${key}` : key);
}
}
return result;
}

const locales = readdirSync(resolve(__dirname, '../locales')).filter((file) => {
return file.endsWith('.json')
})
const defaultKeys = getKeys(en);

describe("should include all keys", () => {
locales.forEach((locale) => {
it.runIf(!locale.startsWith("en-US"))(`for ${locale}`, () => {
expect(getKeys(require(`../locales/${locale}`))).toEqual(defaultKeys)
})
})
})

AltStyle によって変換されたページ (->オリジナル) /