2020-08-03 19:16:13 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import { t, use } from '../index'
|
|
|
|
import localeMixin from '../mixin'
|
|
|
|
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', () => {
|
2020-09-16 14:49:21 +08:00
|
|
|
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)
|
2020-08-03 19:16:13 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
test('mixin', () => {
|
|
|
|
const component = {
|
|
|
|
template: `<p>{{ t('el.popconfirm.cancelButtonText') }}</p>`,
|
|
|
|
mixins: [localeMixin],
|
2020-08-03 21:32:59 +08:00
|
|
|
} as any
|
2020-08-03 19:16:13 +08:00
|
|
|
const wrapper = mount(component)
|
|
|
|
expect(wrapper.text()).toContain('No')
|
|
|
|
})
|
|
|
|
})
|