-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { fetchLatestVersion } from '../api'; | ||
|
||
describe('fetchLatestVersion', () => { | ||
it('should fetch the latest version', async () => { | ||
const version = await fetchLatestVersion(); | ||
expect(version).toBe('v1.2.3'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { camelToKebabCase, kebabToCamelCase } from '../general'; | ||
|
||
describe('camelToKebabCase', () => { | ||
it('should convert camelCase to kebab-case', () => { | ||
expect(camelToKebabCase('camelCaseString')).toBe('camel-case-string'); | ||
}); | ||
}); | ||
|
||
describe('kebabToCamelCase', () => { | ||
it('should convert kebab-case to camelCase', () => { | ||
expect(kebabToCamelCase('kebab-case-string')).toBe('kebabCaseString'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import docsMessages from 'app/docs/locales'; | ||
import { readdir, readFile } from 'fs-extra'; | ||
import { enabled, locales as localeOptions } from 'src/constants/locales'; | ||
import appMessages from 'src/i18n'; | ||
import { camelToKebabCase } from 'src/utils/general'; | ||
import { resolve } from 'upath'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
describe('Locales', () => { | ||
it('should be defined', async () => { | ||
const locales = localeOptions.map((l) => l.value).sort(); | ||
const localesKebab = locales.map(camelToKebabCase).sort(); | ||
|
||
const srcMessages = Object.keys(appMessages); | ||
const docsLocaleMessages = Object.keys(docsMessages).sort(); | ||
|
||
const docsLocaleFiles = ( | ||
await readdir(resolve(__dirname, '../../../docs/locales')) | ||
) | ||
.filter((f) => f.endsWith('.json')) | ||
.map((f) => f.replace('.json', '')) | ||
.sort(); | ||
|
||
const docsSrcFolders = ( | ||
await readdir(resolve(__dirname, '../../../docs/src')) | ||
) | ||
.filter((f) => f !== 'assets' && f !== 'public') | ||
.sort(); | ||
|
||
const srcLocaleFiles = ( | ||
await readdir(resolve(__dirname, '../../../src/i18n')) | ||
) | ||
.filter((f) => f.endsWith('.json')) | ||
.map((f) => f.replace('.json', '')) | ||
.sort(); | ||
|
||
expect(locales).toEqual(docsLocaleMessages); | ||
expect(localesKebab).toEqual(docsLocaleFiles); | ||
expect(localesKebab).toEqual(docsSrcFolders); | ||
expect(localesKebab).toEqual(srcLocaleFiles); | ||
expect(enabled).toEqual(srcMessages); | ||
}); | ||
|
||
it('should not have unused keys for docs', async () => { | ||
const localeMapper = await readFile( | ||
resolve(__dirname, '../../../docs/utils/locales.ts'), | ||
'utf-8', | ||
); | ||
|
||
const config = await readFile( | ||
resolve(__dirname, '../../../docs/.vitepress/config.mts'), | ||
'utf-8', | ||
); | ||
|
||
const docsKeys = Object.keys(docsMessages.en); | ||
docsKeys.forEach((key) => { | ||
expect(localeMapper + config).toContain(key); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters