Skip to content

Commit

Permalink
fix(#621) fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ben12 committed Aug 6, 2023
1 parent 33ab971 commit f35d22f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('transloco-validator', () => {
jest.mocked(fs.readFileSync).mockImplementation(() => '{"test":{"erreur"}}');

const callValidator = () => validator('', ['mytest.json']);
expect(callValidator).toThrowError(new SyntaxError("Unexpected token } in JSON at position 17 (mytest.json)"));
expect(callValidator).toThrowError(new SyntaxError("Expected ':' after property name in JSON at position 17 (mytest.json)"));
})

it('should return success', () => {
Expand Down
16 changes: 15 additions & 1 deletion libs/transloco/src/lib/tests/transpiler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,26 @@ describe('TranslocoTranspiler', () => {

function testDefaultBehaviour(
parser: TranslocoTranspiler,
[start, end]: [string, string] = defaultConfig.interpolation
[start, end, forbiddenChars]: [string, string, string?] = defaultConfig.interpolation
) {
function wrapParam(param: string) {
return `${start} ${param} ${end}`;
}

it('should skip if forbidden chars are used', () => {
if (forbiddenChars?.length) {
for (const char of forbiddenChars) {
const parsed = parser.transpile(
`Hello ${wrapParam('value ' + char)}`,
{ value: 'World' },
{},
'key'
);
expect(parsed).toEqual(`Hello ${wrapParam('value ' + char)}`);
}
}
});

it('should translate simple string from params', () => {
const parsed = parser.transpile(
`Hello ${wrapParam('value')}`,
Expand Down

0 comments on commit f35d22f

Please sign in to comment.