@@ -10,15 +10,15 @@ import { execute } from '../../index';
10
10
import { BASE_OPTIONS , KARMA_BUILDER_INFO , describeKarmaBuilder } from '../setup' ;
11
11
import { BuilderMode } from '../../schema' ;
12
12
13
- describeKarmaBuilder ( execute , KARMA_BUILDER_INFO , ( harness , setupTarget ) => {
13
+ describeKarmaBuilder ( execute , KARMA_BUILDER_INFO , ( harness , setupTarget , isApplicationBuilder ) => {
14
14
describe ( 'Option: "aot"' , ( ) => {
15
- it ( 'enables aot with application builder ' , async ( ) => {
15
+ it ( 'enables aot' , async ( ) => {
16
16
await setupTarget ( harness ) ;
17
17
18
18
await harness . writeFiles ( {
19
19
'src/aot.spec.ts' : `
20
20
import { Component } from '@angular/core';
21
-
21
+
22
22
describe('Hello', () => {
23
23
it('should *not* contain jit instructions', () => {
24
24
@Component({
@@ -32,48 +32,44 @@ describeKarmaBuilder(execute, KARMA_BUILDER_INFO, (harness, setupTarget) => {
32
32
` ,
33
33
} ) ;
34
34
35
- harness . useTarget ( 'test' , {
36
- ...BASE_OPTIONS ,
37
- aot : true ,
38
- /** Cf. {@link ../builder-mode_spec.ts} */
39
- polyfills : [ 'zone.js' , '@angular/localize/init' , 'zone.js/testing' ] ,
40
- builderMode : BuilderMode . Application ,
41
- } ) ;
42
-
43
- const { result } = await harness . executeOnce ( ) ;
44
- expect ( result ?. success ) . toBeTrue ( ) ;
35
+ expect ( await runTest ( { aot : true } ) ) . toBeTrue ( ) ;
45
36
} ) ;
46
37
47
- it ( 'enables aot with browser builder ' , async ( ) => {
38
+ it ( 'is turned off by default ' , async ( ) => {
48
39
await setupTarget ( harness ) ;
49
40
50
41
await harness . writeFiles ( {
51
42
'src/aot.spec.ts' : `
52
43
import { Component } from '@angular/core';
53
-
44
+
54
45
describe('Hello', () => {
55
- it('should *not* contain jit instructions', () => {
46
+ it('should contain jit instructions', () => {
56
47
@Component({
57
48
template: 'Hello',
58
49
})
59
50
class Hello {}
60
51
61
- expect((Hello as any).ɵcmp.template.toString()).not. toContain('jit');
52
+ expect((Hello as any).ɵcmp.template.toString()).toContain('jit');
62
53
});
63
54
});
64
55
` ,
65
56
} ) ;
66
57
67
- harness . useTarget ( 'test' , {
68
- ...BASE_OPTIONS ,
69
- aot : true ,
70
- /** Cf. {@link ../builder-mode_spec.ts} */
71
- polyfills : [ 'zone.js' , '@angular/localize/init' , 'zone.js/testing' ] ,
72
- builderMode : BuilderMode . Browser ,
73
- } ) ;
74
-
75
- const { result } = await harness . executeOnce ( ) ;
76
- expect ( result ?. success ) . toBeTrue ( ) ;
58
+ expect ( await runTest ( ) ) . toBeTrue ( ) ;
77
59
} ) ;
78
60
} ) ;
61
+
62
+ async function runTest ( { aot } : { aot ?: boolean } = { } ) {
63
+ harness . useTarget ( 'test' , {
64
+ ...BASE_OPTIONS ,
65
+ aot,
66
+ /** Cf. {@link ../builder-mode_spec.ts} */
67
+ polyfills : [ 'zone.js' , '@angular/localize/init' , 'zone.js/testing' ] ,
68
+ builderMode : isApplicationBuilder ? BuilderMode . Application : BuilderMode . Browser ,
69
+ } ) ;
70
+
71
+ const { result } = await harness . executeOnce ( ) ;
72
+
73
+ return result ?. success ;
74
+ }
79
75
} ) ;
0 commit comments