ngx-translate-extract/tests/parsers/marker.parser.spec.ts

31 lines
850 B
TypeScript
Raw Normal View History

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