Add support for extracting array of strings in ServiceParser + tests

This commit is contained in:
Kim Biesbjerg
2016-12-08 15:24:23 +01:00
parent 3e84dd2f72
commit fdf26d6af5
2 changed files with 55 additions and 7 deletions

View File

@@ -34,7 +34,7 @@ describe('ServiceParser', () => {
expect(messages).to.equal('_translateService');
});
it('should extract string passed to translateService.get()', () => {
it('should extract strings in TranslateService\'s get() method', () => {
const contents = `
@Component({ })
export class AppComponent {
@@ -47,7 +47,7 @@ describe('ServiceParser', () => {
expect(messages).to.deep.equal(['Hello World']);
});
it('should extract string passed to translateService.instant()', () => {
it('should extract strings in TranslateService\'s instant() method', () => {
const contents = `
@Component({ })
export class AppComponent {
@@ -60,7 +60,33 @@ describe('ServiceParser', () => {
expect(messages).to.deep.equal(['Hello World']);
});
it('should not extract string passed to get() or instant() methods of other services', () => {
it('should extract array of strings in TranslateService\'s get() method', () => {
const contents = `
@Component({ })
export class AppComponent {
public constructor(protected _translateService: TranslateService) { }
public test() {
this._translateService.get(['Hello', 'World']);
}
`;
const messages = parser.process(componentFilename, contents);
expect(messages).to.deep.equal(['Hello', 'World']);
});
it('should extract array of strings in TranslateService\'s instant() method', () => {
const contents = `
@Component({ })
export class AppComponent {
public constructor(protected _translateService: TranslateService) { }
public test() {
this._translateService.instant(['Hello', 'World']);
}
`;
const messages = parser.process(componentFilename, contents);
expect(messages).to.deep.equal(['Hello', 'World']);
});
it('should not extract strings in get()/instant() methods of other services', () => {
const contents = `
@Component({ })
export class AppComponent {