added tests
This commit is contained in:
@@ -30,6 +30,12 @@ describe('PipeParser', () => {
|
|||||||
expect(keys).to.deep.equal(['World']);
|
expect(keys).to.deep.equal(['World']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should extract interpolated strings when translate pipe is used in conjunction with other pipes', () => {
|
||||||
|
const contents = `Hello {{ 'World' | translate | upper }}`;
|
||||||
|
const keys = parser.extract(contents, templateFilename).keys();
|
||||||
|
expect(keys).to.deep.equal(['World']);
|
||||||
|
});
|
||||||
|
|
||||||
it('should extract strings with escaped quotes', () => {
|
it('should extract strings with escaped quotes', () => {
|
||||||
const contents = `Hello {{ 'World\\'s largest potato' | translate }}`;
|
const contents = `Hello {{ 'World\\'s largest potato' | translate }}`;
|
||||||
const keys = parser.extract(contents, templateFilename).keys();
|
const keys = parser.extract(contents, templateFilename).keys();
|
||||||
|
@@ -201,6 +201,21 @@ describe('ServiceParser', () => {
|
|||||||
expect(keys).to.deep.equal([]);
|
expect(keys).to.deep.equal([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not extract variables', () => {
|
||||||
|
const contents = `
|
||||||
|
@Component({ })
|
||||||
|
export class AppComponent {
|
||||||
|
public constructor(protected translateService: TranslateService) { }
|
||||||
|
public test() {
|
||||||
|
this.translateService.get(["yes", variable ]).then(translations => {
|
||||||
|
console.log(translations[variable]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const keys = parser.extract(contents, componentFilename).keys();
|
||||||
|
expect(keys).to.deep.equal(['yes']);
|
||||||
|
});
|
||||||
|
|
||||||
it('should extract strings from all classes in the file', () => {
|
it('should extract strings from all classes in the file', () => {
|
||||||
const contents = `
|
const contents = `
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
Reference in New Issue
Block a user