Skip to content

Commit edbd685

Browse files
committed
fix(#621) fix after rebase
1 parent 33ab971 commit edbd685

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

libs/transloco-validator/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22
import commandLineArgs from 'command-line-args';
3+
34
import validator from './lib/transloco-validator';
45

56

libs/transloco-validator/src/lib/transloco-validator.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import validator from './transloco-validator';
21
import fs from 'fs';
32

3+
import validator from './transloco-validator';
4+
45
jest.mock('fs');
56

67
describe('transloco-validator', () => {
@@ -23,7 +24,7 @@ describe('transloco-validator', () => {
2324
jest.mocked(fs.readFileSync).mockImplementation(() => '{"test":{"erreur"}}');
2425

2526
const callValidator = () => validator('', ['mytest.json']);
26-
expect(callValidator).toThrowError(new SyntaxError("Unexpected token } in JSON at position 17 (mytest.json)"));
27+
expect(callValidator).toThrowError(SyntaxError);
2728
})
2829

2930
it('should return success', () => {

libs/transloco/src/lib/tests/transpiler.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,26 @@ describe('TranslocoTranspiler', () => {
123123

124124
function testDefaultBehaviour(
125125
parser: TranslocoTranspiler,
126-
[start, end]: [string, string] = defaultConfig.interpolation
126+
[start, end, forbiddenChars]: [string, string, string?] = defaultConfig.interpolation
127127
) {
128128
function wrapParam(param: string) {
129129
return `${start} ${param} ${end}`;
130130
}
131131

132+
it('should skip if forbidden chars are used', () => {
133+
if (forbiddenChars?.length) {
134+
for (const char of forbiddenChars) {
135+
const parsed = parser.transpile(
136+
`Hello ${wrapParam('value ' + char)}`,
137+
{ value: 'World' },
138+
{},
139+
'key'
140+
);
141+
expect(parsed).toEqual(`Hello ${wrapParam('value ' + char)}`);
142+
}
143+
}
144+
});
145+
132146
it('should translate simple string from params', () => {
133147
const parsed = parser.transpile(
134148
`Hello ${wrapParam('value')}`,

0 commit comments

Comments
 (0)