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 edbd685
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions libs/transloco-validator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
import commandLineArgs from 'command-line-args';

import validator from './lib/transloco-validator';


Expand Down
5 changes: 3 additions & 2 deletions libs/transloco-validator/src/lib/transloco-validator.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import validator from './transloco-validator';
import fs from 'fs';

import validator from './transloco-validator';

jest.mock('fs');

describe('transloco-validator', () => {
Expand All @@ -23,7 +24,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(SyntaxError);
})

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 edbd685

Please sign in to comment.