Tests about support of HTML tags in translations keys with GetText (#172)

- Verify that html tags are supported in translation keys
- Add typed support of gettext-parser
This commit is contained in:
Lorent Lempereur
2020-04-01 12:19:30 +02:00
committed by GitHub
parent 73f39d625c
commit 71f4f42b33
8 changed files with 63 additions and 8 deletions

View File

@@ -36,6 +36,12 @@ describe('DirectiveParser', () => {
expect(keys).to.deep.equal(['Hello <strong translate>World</strong>']);
});
it('should not exclude html tags in children', () => {
const contents = `<div translate>Hello <strong>World</strong></div>`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal(['Hello <strong>World</strong>']);
});
it('should extract and parse inline template', () => {
const contents = `
@Component({

View File

@@ -36,6 +36,17 @@ describe('MarkerParser', () => {
expect(keys).to.deep.equal(['Hello world', 'This is a very very very very long line.', 'Mix of different types']);
});
it('should extract split strings while keeping html tags', () => {
const contents = `
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
_('Hello ' + 'world');
_('This <em>is</em> a ' + 'very ' + 'very ' + 'very ' + 'very ' + 'long line.');
_('Mix ' + \`of \` + 'different ' + \`types\`);
`;
const keys = parser.extract(contents, componentFilename).keys();
expect(keys).to.deep.equal(['Hello world', 'This <em>is</em> a very very very very long line.', 'Mix of different types']);
});
it('should extract the strings', () => {
const contents = `
import { marker } from '@biesbjerg/ngx-translate-extract-marker';