Alan f4691a545a feat(@schematics/angular): add migration to enable AOT by default
With this change we enable the AOT option for the browser builder when an application will use Ivy as rendering engine.
2019-08-30 00:08:52 +05:30

108 lines
2.9 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { HostTree } from '@angular-devkit/schematics';
import { isIvyEnabled } from './utils';
describe('migrations update-9 utils', () => {
describe('isIvyEnabled', () => {
let tree: HostTree;
beforeEach(() => {
tree = new HostTree();
});
it('should return false when disabled in base tsconfig', () => {
tree.create('tsconfig.json', JSON.stringify({
angularCompilerOptions: {
enableIvy: false,
},
}));
tree.create('foo/tsconfig.app.json', JSON.stringify({
extends: '../tsconfig.json',
}));
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false);
});
it('should return true when enable in child tsconfig but disabled in base tsconfig', () => {
tree.create('tsconfig.json', JSON.stringify({
angularCompilerOptions: {
enableIvy: false,
},
}));
tree.create('foo/tsconfig.app.json', JSON.stringify({
extends: '../tsconfig.json',
angularCompilerOptions: {
enableIvy: true,
},
}));
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(true);
});
it('should return false when disabled in child tsconfig but enabled in base tsconfig', () => {
tree.create('tsconfig.json', JSON.stringify({
angularCompilerOptions: {
enableIvy: true,
},
}));
tree.create('foo/tsconfig.app.json', JSON.stringify({
extends: '../tsconfig.json',
angularCompilerOptions: {
enableIvy: false,
},
}));
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false);
});
it('should return false when disabled in base with multiple extends', () => {
tree.create('tsconfig.json', JSON.stringify({
angularCompilerOptions: {
enableIvy: false,
},
}));
tree.create('foo/tsconfig.project.json', JSON.stringify({
extends: '../tsconfig.json',
}));
tree.create('foo/tsconfig.app.json', JSON.stringify({
extends: './tsconfig.project.json',
}));
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false);
});
it('should return true when enable in intermediate tsconfig with multiple extends', () => {
tree.create('tsconfig.json', JSON.stringify({
angularCompilerOptions: {
enableIvy: false,
},
}));
tree.create('foo/tsconfig.project.json', JSON.stringify({
extends: '../tsconfig.json',
angularCompilerOptions: {
enableIvy: true,
},
}));
tree.create('foo/tsconfig.app.json', JSON.stringify({
extends: './tsconfig.project.json',
}));
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(true);
});
});
});