From deb38eb7c30b04401c27d242f1ee978b96fbcbf2 Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Thu, 13 Jun 2019 11:59:36 +0200 Subject: [PATCH] (test) add test --- src/compilers/po.compiler.ts | 2 +- src/utils/translation.collection.ts | 4 ++-- tests/parsers/utils.spec.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/compilers/po.compiler.ts b/src/compilers/po.compiler.ts index 6aa42eb..a59a9f6 100644 --- a/src/compilers/po.compiler.ts +++ b/src/compilers/po.compiler.ts @@ -29,7 +29,7 @@ export class PoCompiler implements CompilerInterface { msgstr: collection.get(key) }; return translations; - }, {}) + }, {} as any) } }; diff --git a/src/utils/translation.collection.ts b/src/utils/translation.collection.ts index 571ee25..dd77f15 100644 --- a/src/utils/translation.collection.ts +++ b/src/utils/translation.collection.ts @@ -1,5 +1,5 @@ export interface TranslationType { - [key: string]: string + [key: string]: string; } export class TranslationCollection { @@ -18,7 +18,7 @@ export class TranslationCollection { const values = keys.reduce((results, key) => { results[key] = ''; return results; - }, {}); + }, {} as TranslationType); return new TranslationCollection({ ...this.values, ...values }); } diff --git a/tests/parsers/utils.spec.ts b/tests/parsers/utils.spec.ts index 7ea151c..59a1b98 100644 --- a/tests/parsers/utils.spec.ts +++ b/tests/parsers/utils.spec.ts @@ -31,6 +31,18 @@ describe('Utils', () => { expect(template).to.equal('

Hello World

'); }); + it('should extract inline template without html', () => { + const contents = ` + @Component({ + selector: 'test', + template: 'Hello World' + }) + export class TestComponent { } + `; + const template = extractComponentInlineTemplate(contents); + expect(template).to.equal('Hello World'); + }); + it('should extract inline template spanning multiple lines', () => { const contents = ` @Component({