Add support for extracting strings from multiple classes per file. Closes #46

This commit is contained in:
Kim Biesbjerg
2017-05-09 20:08:44 +02:00
parent 4e351405fb
commit d416c6b9fd
2 changed files with 43 additions and 28 deletions

View File

@@ -164,4 +164,25 @@ describe('ServiceParser', () => {
expect(keys).to.deep.equal([]);
});
it('should extract strings from all classes in the file', () => {
const contents = `
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
export class Stuff {
thing: string;
constructor(thing: string) {
this.thing = thing;
}
}
@Injectable()
export class AuthService {
constructor(public translate: TranslateService) {
console.log(this.translate.instant("Hello!"));
}
}
`;
const keys = parser.extract(contents, componentFilename).keys();
expect(keys).to.deep.equal(['Hello!']);
});
});