Skip to content

Commit b17c10b

Browse files
Filip Pasternakakameco
authored andcommitted
Test case for use with custom module.
1 parent 787295b commit b17c10b

File tree

7 files changed

+71
-5
lines changed

7 files changed

+71
-5
lines changed

test/fixtures/custom/a/messages.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineMessages } from '../i18n'
2+
3+
export default defineMessages({
4+
hello: {
5+
id: 'a.custom.hello',
6+
defaultMessage: 'hello'
7+
},
8+
world: {
9+
id: 'a.custom.world',
10+
defaultMessage: 'world'
11+
}
12+
})

test/fixtures/custom/b/messages.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineMessages } from '../i18n'
2+
3+
export default defineMessages({
4+
hello: {
5+
id: 'b.custom.message',
6+
defaultMessage: 'Message'
7+
}
8+
})

test/fixtures/custom/i18n.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { defineMessages } from 'react-intl'

test/json/snapshots/test.js.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,39 @@ Generated by [AVA](https://ava.li).
132132
'c.hello',
133133
'y.hello',
134134
'z.hello',
135-
]
135+
136+
## export using custom module
137+
138+
> Snapshot 1
139+
140+
{
141+
'a.custom.hello': 'hello',
142+
'a.custom.world': 'world',
143+
'b.custom.message': 'Message',
144+
}
145+
146+
> Snapshot 2
147+
148+
{
149+
'a.custom.hello': '',
150+
'a.custom.world': '',
151+
'b.custom.message': '',
152+
}
153+
154+
## export using custom module
155+
156+
> Snapshot 1
157+
158+
{
159+
'a.custom.hello': 'hello',
160+
'a.custom.world': 'world',
161+
'b.custom.message': 'Message',
162+
}
163+
164+
> Snapshot 2
165+
166+
{
167+
'a.custom.hello': '',
168+
'a.custom.world': '',
169+
'b.custom.message': '',
170+
}

test/json/snapshots/test.js.snap

83 Bytes
Binary file not shown.

test/json/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ test('delimiter - nest', async t => {
6464
t.snapshot(en)
6565
t.snapshot(ja)
6666
})
67+
68+
test('export using custom module', async t => {
69+
const tmp = tempy.directory()
70+
const opts = { moduleName: '../i18n' }
71+
await m(['en', 'ja'], 'test/fixtures/custom/**/*.js', tmp, opts)
72+
const en = JSON.parse(fs.readFileSync(path.resolve(tmp, 'en.json'), 'utf8'))
73+
const ja = JSON.parse(fs.readFileSync(path.resolve(tmp, 'ja.json'), 'utf8'))
74+
t.snapshot(en)
75+
t.snapshot(ja)
76+
})

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,10 +2021,10 @@ extglob@^2.0.4:
20212021
snapdragon "^0.8.1"
20222022
to-regex "^3.0.1"
20232023

2024-
extract-react-intl@^0.8.1:
2025-
version "0.8.1"
2026-
resolved "https://registry.yarnpkg.com/extract-react-intl/-/extract-react-intl-0.8.1.tgz#09a585e4c3bd816be993e24f8d77945356b8a8e6"
2027-
integrity sha512-NsU2pqsxUtYKG4EPaYHIwW1EJTSSd9gmqEjBwbJeq5PNkPJmOui5wp7KzH56MldvopEJp7bKx0UX98L1hkXJIg==
2024+
extract-react-intl@^0.9.0:
2025+
version "0.9.0"
2026+
resolved "https://registry.yarnpkg.com/extract-react-intl/-/extract-react-intl-0.9.0.tgz#7eb9de48d222d483eefd4975afc965a1a43e667a"
2027+
integrity sha512-O/AqANf7QIXlZPvXeuBr8aXbK/sFMZ0gn26YcRXUSsBaSSFHEvXVrLlQO6nGTAOOVghLoVRS52im5ylPbpdD6g==
20282028
dependencies:
20292029
"@babel/core" "^7.0.0"
20302030
babel-plugin-react-intl "^3.0.1"

0 commit comments

Comments
 (0)