From 3e43fde1cccd6e09898b6943a99a697c4aaf8339 Mon Sep 17 00:00:00 2001 From: Kim Biesbjerg Date: Thu, 13 Jun 2019 12:17:04 +0200 Subject: [PATCH] (test) fix tests --- tests/parsers/directive.parser.spec.ts | 8 +------- tests/parsers/pipe.parser.spec.ts | 26 +++++++++++++++++++------- tests/parsers/utils.spec.ts | 4 ++-- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/parsers/directive.parser.spec.ts b/tests/parsers/directive.parser.spec.ts index b01e690..b110977 100644 --- a/tests/parsers/directive.parser.spec.ts +++ b/tests/parsers/directive.parser.spec.ts @@ -107,7 +107,7 @@ describe('DirectiveParser', () => { }); it('should not extract translate pipe in html tag', () => { - const contents = `

{{ 'Audiobooks for personal development' | translate }}

`; + const contents = `

{{ 'Audiobooks for personal development' | translate }}

`; const collection = parser.extract(contents, templateFilename); expect(collection.values).to.deep.equal({}); }); @@ -124,10 +124,4 @@ describe('DirectiveParser', () => { expect(keys).to.deep.equal(['Hello World']); }); - it('should not extract variables', () => { - const contents = '

{{ message | translate }}

'; - const keys = parser.extract(contents, templateFilename).keys(); - expect(keys).to.deep.equal([]); - }); - }); diff --git a/tests/parsers/pipe.parser.spec.ts b/tests/parsers/pipe.parser.spec.ts index 0926ffd..52c4099 100644 --- a/tests/parsers/pipe.parser.spec.ts +++ b/tests/parsers/pipe.parser.spec.ts @@ -43,13 +43,13 @@ describe('PipeParser', () => { }); it('should extract interpolated strings using translate pipe in attributes', () => { - const contents = ``; + const contents = ``; const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal(['Hello World']); }); it('should extract bound strings using translate pipe in attributes', () => { - const contents = ``; + const contents = ``; const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal(['Hello World']); }); @@ -58,14 +58,14 @@ describe('PipeParser', () => { const contents = ` - {{ 'Info' | translate }} + {{ 'Info' | translate }} - {{ 'Loading...' | translate }} + {{ 'Loading...' | translate }} @@ -75,7 +75,7 @@ describe('PipeParser', () => { }); it('should extract strings on same line', () => { - const contents = ``; + const contents = ``; const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal(['Hello', 'World']); }); @@ -85,7 +85,7 @@ describe('PipeParser', () => { - +

@@ -94,11 +94,23 @@ describe('PipeParser', () => {

- +
`; const keys = parser.extract(contents, templateFilename).keys(); expect(keys).to.deep.equal(['Name', 'Create account']); }); + it('should not extract variables', () => { + const contents = '

{{ message | translate }}

'; + const keys = parser.extract(contents, templateFilename).keys(); + expect(keys).to.deep.equal([]); + }); + + it('should be able to extract without html', () => { + const contents = `{{ 'message' | translate }}`; + const keys = parser.extract(contents, templateFilename).keys(); + expect(keys).to.deep.equal(['message']); + }); + }); diff --git a/tests/parsers/utils.spec.ts b/tests/parsers/utils.spec.ts index 59a1b98..0cfe3c0 100644 --- a/tests/parsers/utils.spec.ts +++ b/tests/parsers/utils.spec.ts @@ -35,12 +35,12 @@ describe('Utils', () => { const contents = ` @Component({ selector: 'test', - template: 'Hello World' + template: '{{ "Hello World" | translate }}' }) export class TestComponent { } `; const template = extractComponentInlineTemplate(contents); - expect(template).to.equal('Hello World'); + expect(template).to.equal('{{ "Hello World" | translate }}'); }); it('should extract inline template spanning multiple lines', () => {