-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
resource-compilation.test.ts
36 lines (31 loc) · 1.34 KB
/
resource-compilation.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import path from 'path'
import { bundleAndRun } from './utils'
import { createMessageContext } from '@intlify/core-base'
const options = {
target: './fixtures/locales/',
include: [path.resolve(__dirname, './fixtures/locales/**')]
}
test('json resource', async () => {
const { module } = await bundleAndRun('ja.json', options)
const fn = module.message
// expect(fn.source).toEqual(`@.caml:{'no apples'} | {0} apple | {n} apples`)
expect(fn(createMessageContext({ named: { n: 3 } }))).toEqual(`3 apples`)
})
test('json5 resource', async () => {
const { module } = await bundleAndRun('en.json5', options)
const fn = module.message
// expect(fn.source).toEqual(`@.caml:{'no apples'} | {0} apple | {n} apples`)
expect(fn(createMessageContext({ named: { n: 3 } }))).toEqual(`3 apples`)
})
test('yaml resource', async () => {
const { module } = await bundleAndRun('ko.yaml', options)
const fn = module.message
// expect(fn.source).toEqual(`@.caml:{'no apples'} | {0} apple | {n} apples`)
expect(fn(createMessageContext({ named: { n: 3 } }))).toEqual(`3 apples`)
})
test('yml resource', async () => {
const { module } = await bundleAndRun('fr.yml', options)
const fn = module.message
// expect(fn.source).toEqual(`@.caml:{'no apples'} | {0} apple | {n} apples`)
expect(fn(createMessageContext({ named: { n: 3 } }))).toEqual(`3 apples`)
})