-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from JuckZ/develop
fix: Missing i18n partial translation prevents startup
- Loading branch information
Showing
10 changed files
with
133 additions
and
1 deletion.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
import { beforeAll, describe, expect, it } from 'vitest'; | ||
import chalk from 'chalk'; | ||
|
||
import enPack from '../locale/en'; | ||
import zhPack from '../locale/zh-cn'; | ||
|
||
let languagePack; | ||
describe('i18n', () => { | ||
beforeAll(() => { | ||
localStorage.setItem('language', 'zh'); | ||
}); | ||
it('localstorage work fine', () => { | ||
expect(localStorage.getItem('name')).null; | ||
localStorage.setItem('name', 'awesome'); | ||
expect(localStorage.getItem('name')).eq('awesome'); | ||
}); | ||
|
||
it('should return selected lang', async () => { | ||
languagePack = (await import('../i18n')).default; | ||
console.log(languagePack); | ||
expect(languagePack['__FOR_TEST'].exist.child).eq(zhPack['__FOR_TEST'].exist.child); | ||
}); | ||
|
||
it('should return default lang', () => { | ||
expect(languagePack['__FOR_TEST'].notExist.child).eq(enPack['__FOR_TEST'].notExist.child); | ||
}); | ||
}); |
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,53 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { deepClone, deepCloneArr, deepCloneObj } from '../../utils/common'; | ||
|
||
const obj1 = { | ||
name: 'John', | ||
age: 30, | ||
address: { | ||
city: 'New York', | ||
state: 'NY', | ||
}, | ||
skills: [ | ||
'js', | ||
'ts', | ||
'py', | ||
() => { | ||
console.log(111); | ||
}, | ||
], | ||
}; | ||
const arr1 = [ | ||
{ name: 'John', age: 30 }, | ||
{ name: 'Mary', age: 25 }, | ||
{ | ||
name: 'Bob', | ||
age: 40, | ||
skill() { | ||
console.log('js'); | ||
}, | ||
}, | ||
{ | ||
others: [ | ||
{ name: 'Mary', age: 25 }, | ||
{ name: 'Bob', age: 40 }, | ||
], | ||
}, | ||
]; | ||
|
||
describe('common utils', () => { | ||
it('placeholder', () => { | ||
expect(1 + 1).toBe(2); | ||
}); | ||
// it('clone object[]', () => { | ||
// const arr2 = deepCloneArr(arr1); | ||
// expect(arr1).not.toBe(arr2); | ||
// expect(arr1).toEqual(arr2); | ||
// }); | ||
|
||
// it('clone object', async () => { | ||
// const obj2 = deepCloneObj(obj1); | ||
// expect(obj1).not.toBe(obj2); | ||
// expect(obj1).toEqual(obj2); | ||
// }); | ||
}); |
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
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
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,7 @@ | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
test: { | ||
environment: 'jsdom', | ||
}, | ||
}); |