-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.spec.ts
81 lines (73 loc) · 2.3 KB
/
errors.spec.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import vue3base from '@vitejs/plugin-vue'
import compiler from '@vue/compiler-sfc'
import { ExternalFluentPlugin, SFCFluentPlugin } from '../../../src/vite'
import { compile } from './util'
const vue3 = () => vue3base({
compiler,
})
const baseDir = resolve(__dirname, '../..')
describe('Error checking', () => {
it('checks for syntax errors in external ftl files', async () => {
// Arrange
// Act
const code = compile({
plugins: [
vue3(),
ExternalFluentPlugin({
baseDir: resolve(baseDir, 'fixtures'),
ftlDir: resolve(baseDir, 'fixtures/ftl'),
locales: ['en', 'da'],
checkSyntax: true,
}),
],
}, '/fixtures/components/errors.vue')
// Assert
await expect(code).rejects.toThrowErrorMatchingInlineSnapshot(`
"Fluent parse errors:
E0003: Expected token: \\"}\\" (2:31)
1 | # Simple things are simple.
2 | hello-user = Hello, {$userName!
| ^
3 |
4 | # Complex things are possible.
E0010: Expected one of the variants to be marked as default (*) (9:3)
7 | [one] added one photo
8 | [other] added {$photoCount} new photo
9 | }to {$userGender ->
| ^
10 | [male] his stream
11 | [female] her stream"
`)
})
it('checks for syntax errors in custom blocks', async () => {
// Arrange
// Act
const code = compile({
plugins: [
vue3(),
SFCFluentPlugin({
checkSyntax: true,
}),
],
}, '/fixtures/errors.vue')
// Assert
await expect(code).rejects.toThrowErrorMatchingInlineSnapshot(`
"Fluent parse errors:
E0003: Expected token: \\"}\\" (2:31)
1 | # Simple things are simple.
2 | hello-user = Hello, {$userName!
| ^
3 |
4 | # Complex things are possible.
E0010: Expected one of the variants to be marked as default (*) (9:3)
7 | [one] added one photo
8 | [other] added {$photoCount} new photo
9 | }to {$userGender ->
| ^
10 | [male] his stream
11 | [female] her stream"
`)
})
})