(test) fix tests
This commit is contained in:
		| @@ -107,7 +107,7 @@ describe('DirectiveParser', () => { | |||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should not extract translate pipe in html tag', () => { | 	it('should not extract translate pipe in html tag', () => { | ||||||
| 		const contents = `<p>{{ 'Audiobooks for personal development' | translate }}</p>`; | 		const contents = `<p>{{ 'Audiobooks for personal development' | translate }}</p>`; | ||||||
| 		const collection = parser.extract(contents, templateFilename); | 		const collection = parser.extract(contents, templateFilename); | ||||||
| 		expect(collection.values).to.deep.equal({}); | 		expect(collection.values).to.deep.equal({}); | ||||||
| 	}); | 	}); | ||||||
| @@ -124,10 +124,4 @@ describe('DirectiveParser', () => { | |||||||
| 		expect(keys).to.deep.equal(['Hello World']); | 		expect(keys).to.deep.equal(['Hello World']); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should not extract variables', () => { |  | ||||||
| 		const contents = '<p>{{ message | translate }}</p>'; |  | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); |  | ||||||
| 		expect(keys).to.deep.equal([]); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -43,13 +43,13 @@ describe('PipeParser', () => { | |||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should extract interpolated strings using translate pipe in attributes', () => { | 	it('should extract interpolated strings using translate pipe in attributes', () => { | ||||||
| 		const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`; | 		const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`; | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
| 		expect(keys).to.deep.equal(['Hello World']); | 		expect(keys).to.deep.equal(['Hello World']); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should extract bound strings using translate pipe in attributes', () => { | 	it('should extract bound strings using translate pipe in attributes', () => { | ||||||
| 		const contents = `<span [attr]="'Hello World' | translate"></span>`; | 		const contents = `<span [attr]="'Hello World' | translate"></span>`; | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
| 		expect(keys).to.deep.equal(['Hello World']); | 		expect(keys).to.deep.equal(['Hello World']); | ||||||
| 	}); | 	}); | ||||||
| @@ -58,14 +58,14 @@ describe('PipeParser', () => { | |||||||
| 		const contents = ` | 		const contents = ` | ||||||
| 			<ion-header> | 			<ion-header> | ||||||
| 				<ion-navbar color="brand"> | 				<ion-navbar color="brand"> | ||||||
| 					<ion-title>{{ 'Info' | translate }}</ion-title> | 					<ion-title>{{ 'Info' | translate }}</ion-title> | ||||||
| 				</ion-navbar> | 				</ion-navbar> | ||||||
| 			</ion-header> | 			</ion-header> | ||||||
|  |  | ||||||
| 			<ion-content> | 			<ion-content> | ||||||
|  |  | ||||||
| 				<content-loading *ngIf="isLoading"> | 				<content-loading *ngIf="isLoading"> | ||||||
| 					{{ 'Loading...' | translate }} | 					{{ 'Loading...' | translate }} | ||||||
| 				</content-loading> | 				</content-loading> | ||||||
|  |  | ||||||
| 			</ion-content> | 			</ion-content> | ||||||
| @@ -75,7 +75,7 @@ describe('PipeParser', () => { | |||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
| 	it('should extract strings on same line', () => { | 	it('should extract strings on same line', () => { | ||||||
| 		const contents = `<span [attr]="'Hello' | translate"></span><span [attr]="'World' | translate"></span>`; | 		const contents = `<span [attr]="'Hello' | translate"></span><span [attr]="'World' | translate"></span>`; | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
| 		expect(keys).to.deep.equal(['Hello', 'World']); | 		expect(keys).to.deep.equal(['Hello', 'World']); | ||||||
| 	}); | 	}); | ||||||
| @@ -85,7 +85,7 @@ describe('PipeParser', () => { | |||||||
| 			<ion-list inset> | 			<ion-list inset> | ||||||
| 				<ion-item> | 				<ion-item> | ||||||
| 					<ion-icon item-left name="person" color="dark"></ion-icon> | 					<ion-icon item-left name="person" color="dark"></ion-icon> | ||||||
| 					<ion-input formControlName="name" type="text" [placeholder]="'Name' | translate"></ion-input> | 					<ion-input formControlName="name" type="text" [placeholder]="'Name' | translate"></ion-input> | ||||||
| 				</ion-item> | 				</ion-item> | ||||||
| 				<ion-item> | 				<ion-item> | ||||||
| 					<p color="danger" danger *ngFor="let error of form.get('name').getError('remote')"> | 					<p color="danger" danger *ngFor="let error of form.get('name').getError('remote')"> | ||||||
| @@ -94,11 +94,23 @@ describe('PipeParser', () => { | |||||||
| 				</ion-item> | 				</ion-item> | ||||||
| 			</ion-list> | 			</ion-list> | ||||||
| 			<div class="form-actions"> | 			<div class="form-actions"> | ||||||
| 				<button ion-button (click)="onSubmit()" color="secondary" block>{{ 'Create account' | translate }}</button> | 				<button ion-button (click)="onSubmit()" color="secondary" block>{{ 'Create account' | translate }}</button> | ||||||
| 			</div> | 			</div> | ||||||
| 		`; | 		`; | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
| 		expect(keys).to.deep.equal(['Name', 'Create account']); | 		expect(keys).to.deep.equal(['Name', 'Create account']); | ||||||
| 	}); | 	}); | ||||||
|  |  | ||||||
|  | 	it('should not extract variables', () => { | ||||||
|  | 		const contents = '<p>{{ message | translate }}</p>'; | ||||||
|  | 		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']); | ||||||
|  | 	}); | ||||||
|  |  | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -35,12 +35,12 @@ describe('Utils', () => { | |||||||
| 		const contents = ` | 		const contents = ` | ||||||
| 			@Component({ | 			@Component({ | ||||||
| 				selector: 'test', | 				selector: 'test', | ||||||
| 				template: 'Hello World' | 				template: '{{ "Hello World" | translate }}' | ||||||
| 			}) | 			}) | ||||||
| 			export class TestComponent { } | 			export class TestComponent { } | ||||||
| 		`; | 		`; | ||||||
| 		const template = extractComponentInlineTemplate(contents); | 		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', () => { | 	it('should extract inline template spanning multiple lines', () => { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user