refactor(compiler): align &ngsp; handling with Angular Dart implementation (#18774)

PR Close #18774
This commit is contained in:
Pawel Kozlowski
2017-08-18 15:00:12 +02:00
committed by Miško Hevery
parent 7f4c964eef
commit 7d72d0eb9b
3 changed files with 35 additions and 13 deletions

View File

@ -2071,6 +2071,12 @@ The pipe 'test' could not be found ("{{[ERROR ->]a | test}}"): TestComp@0:2`);
describe('whitespaces removal', () => {
beforeEach(() => {
TestBed.configureCompiler({providers: [TEST_COMPILER_PROVIDERS, MOCK_SCHEMA_REGISTRY]});
});
commonBeforeEach();
it('should not remove whitespaces by default', () => {
expect(humanizeTplAst(parse(' <br> <br>\t<br>\n<br> ', []))).toEqual([
[TextAst, ' '],
@ -2085,6 +2091,18 @@ The pipe 'test' could not be found ("{{[ERROR ->]a | test}}"): TestComp@0:2`);
]);
});
it('should replace each &ngsp; with a space when preserveWhitespaces is true', () => {
expect(humanizeTplAst(parse('foo&ngsp;&ngsp;&ngsp;bar', [], [], [], true))).toEqual([
[TextAst, 'foo bar'],
]);
});
it('should replace every &ngsp; with a single space when preserveWhitespaces is false', () => {
expect(humanizeTplAst(parse('foo&ngsp;&ngsp;&ngsp;bar', [], [], [], false))).toEqual([
[TextAst, 'foo bar'],
]);
});
it('should remove whitespaces when explicitly requested', () => {
expect(humanizeTplAst(parse(' <br> <br>\t<br>\n<br> ', [], [], [], false))).toEqual([
[ElementAst, 'br'],