element-plus/packages/locale/__test__/locale.spec.ts

21 lines
503 B
TypeScript
Raw Normal View History

2020-08-03 19:16:13 +08:00
import { t, use } from '../index'
import zhCn from '../lang/zh-cn'
2020-08-03 21:32:59 +08:00
import en from '../lang/en'
2020-08-03 19:16:13 +08:00
describe('Locale', () => {
test('t', () => {
expect(t('el.popconfirm.confirmButtonText')).toBe('Yes')
})
test('return key name if not defined', () => {
expect(t('el.popconfirm.someThing')).toBeUndefined()
2020-08-03 19:16:13 +08:00
})
test('use', () => {
use(zhCn)
expect(t('el.popconfirm.confirmButtonText')).toBe('确定')
2020-08-03 21:32:59 +08:00
use(en)
expect(t('el.popconfirm.confirmButtonText')).toBe('Yes')
2020-08-03 19:16:13 +08:00
})
})