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

34 lines
1.0 KiB
TypeScript
Raw Normal View History

2016-12-08 16:12:43 +03:00
import { expect } from 'chai';
2016-12-08 16:28:59 +03:00
import { PipeParser } from '../../src/parsers/pipe.parser';
2016-12-08 16:12:43 +03:00
describe('PipeParser', () => {
const templateFilename: string = 'test.template.html';
let parser: PipeParser;
beforeEach(() => {
parser = new PipeParser();
});
it('should extract interpolated strings using translate pipe', () => {
const contents = `Hello {{ 'World' | translate }}`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal(['World']);
2016-12-08 16:12:43 +03:00
});
it('should extract interpolated strings using translate pipe in attributes', () => {
const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal(['Hello World']);
2016-12-08 16:12:43 +03:00
});
it('should extract bound strings using translate pipe in attributes', () => {
const contents = `<span [attr]="'Hello World' | translate"></span>`;
const keys = parser.extract(contents, templateFilename).keys();
expect(keys).to.deep.equal(['Hello World']);
2016-12-08 16:12:43 +03:00
});
});