2017-03-30 15:37:30 +03:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
|
|
|
import { FunctionParser } from '../../src/parsers/function.parser';
|
|
|
|
|
|
|
|
describe('FunctionParser', () => {
|
|
|
|
|
|
|
|
const componentFilename: string = 'test.component.ts';
|
|
|
|
|
|
|
|
let parser: FunctionParser;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
parser = new FunctionParser();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should extract strings using marker function', () => {
|
|
|
|
const contents = `
|
|
|
|
import { _ } from '@biesbjerg/ngx-translate-extract';
|
|
|
|
_('Hello world');
|
|
|
|
_(['I', 'am', 'extracted']);
|
|
|
|
otherFunction('But I am not');
|
2019-06-13 12:23:37 +03:00
|
|
|
_(message || 'binary expression');
|
|
|
|
_(message ? message : 'conditional operator');
|
2017-03-30 15:37:30 +03:00
|
|
|
`;
|
|
|
|
const keys = parser.extract(contents, componentFilename).keys();
|
2019-06-13 12:23:37 +03:00
|
|
|
expect(keys).to.deep.equal(['Hello world', 'I', 'am', 'extracted', 'binary expression', 'conditional operator']);
|
2017-03-30 15:37:30 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|