test: add jest
This commit is contained in:
16
src/__tests__/utils.test.ts
Normal file
16
src/__tests__/utils.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import localeEN from '../i18n/locales/en'
|
||||
import localeZH from '../i18n/locales/zh'
|
||||
import { highlightJSON } from '../utils'
|
||||
|
||||
test('highlightJSON', () => {
|
||||
const str = JSON.stringify({ a: 1, b: '2' })
|
||||
expect(highlightJSON(str)).toMatch('key')
|
||||
expect(highlightJSON(str)).toMatch('number')
|
||||
expect(highlightJSON(str)).toMatch('string')
|
||||
})
|
||||
|
||||
test('check locales completeness', () => {
|
||||
const zh = Reflect.ownKeys(localeZH).sort()
|
||||
const en = Reflect.ownKeys(localeEN).sort()
|
||||
expect(zh).toEqual(en)
|
||||
})
|
||||
@@ -97,7 +97,7 @@ export const NONE = 'none'
|
||||
|
||||
export const TRIGGER_PROBABILITY = 0.1
|
||||
|
||||
export const SPECIAL_AVATARS: Readonly<AvatarOption>[] = [
|
||||
export const SPECIAL_AVATARS: Readonly<AvatarOption[]> = [
|
||||
{
|
||||
wrapperShape: 'squircle',
|
||||
background: {
|
||||
|
||||
@@ -102,7 +102,7 @@ export function getRandomAvatarOption(
|
||||
return avatarOption
|
||||
}
|
||||
|
||||
export function getSpecialAvatarOption() {
|
||||
export function getSpecialAvatarOption(): AvatarOption {
|
||||
return SPECIAL_AVATARS[Math.floor(Math.random() * SPECIAL_AVATARS.length)]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user