fix(ivy): take preserveWhitespaces config option into account (FW-650) (#27197)

PR Close #27197
This commit is contained in:
Andrew Kushnir
2018-11-20 10:51:16 -08:00
committed by Jason Aden
parent 9e391e010c
commit d819c00fee
5 changed files with 47 additions and 5 deletions

View File

@ -553,6 +553,46 @@ describe('ngtsc behavioral tests', () => {
expect(trim(jsContents)).toContain(trim(hostBindingsFn));
});
it('should take preserveWhitespaces config option into account', () => {
env.tsconfig({preserveWhitespaces: true});
env.write(`test.ts`, `
import {Component} from '@angular/core';
@Component({
selector: 'test',
template: \`
<div>
Template with whitespaces
</div>
\`
})
class FooCmp {}
`);
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents)
.toContain('text(2, "\\n Template with whitespaces\\n ");');
});
it('@Component\'s preserveWhitespaces should override the one defined in config', () => {
env.tsconfig({preserveWhitespaces: true});
env.write(`test.ts`, `
import {Component} from '@angular/core';
@Component({
selector: 'test',
preserveWhitespaces: false,
template: \`
<div>
Template with whitespaces
</div>
\`
})
class FooCmp {}
`);
env.driveMain();
const jsContents = env.getContents('test.js');
expect(jsContents).toContain('text(1, " Template with whitespaces ");');
});
it('should correctly recognize local symbols', () => {
env.tsconfig();
env.write('module.ts', `