@@ -5,29 +5,44 @@ import { ng } from '../../../utils/process';
5
5
import { expectToFail } from '../../../utils/utils' ;
6
6
7
7
8
- export default function ( ) {
9
- return Promise . resolve ( )
10
- . then ( ( ) => expectToFail ( ( ) => ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' ) ) )
11
- . then ( ( ) => ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' , 'false' ) )
12
- . then ( ( ) => ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' ) )
13
- . then ( ( { stdout } ) => {
14
- if ( ! stdout . match ( / f a l s e \n ? / ) ) {
15
- throw new Error ( `Expected "false", received "${ JSON . stringify ( stdout ) } ".` ) ;
16
- }
17
- } )
18
- // This test requires schema querying capabilities
19
- // .then(() => expectToFail(() => {
20
- // return ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN');
21
- // }))
22
- . then ( ( ) => ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' , 'true' ) )
23
- . then ( ( ) => ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' ) )
24
- . then ( ( { stdout } ) => {
25
- if ( ! stdout . match ( / t r u e \n ? / ) ) {
26
- throw new Error ( `Expected "true", received "${ JSON . stringify ( stdout ) } ".` ) ;
27
- }
28
- } )
29
- . then ( ( ) => expectToFail ( ( ) => ng ( 'config' , '--global' , 'cli.warnings.notreal' , 'true' ) ) )
30
- . then ( ( ) => ng ( 'config' , '--global' , 'cli.warnings.versionMismatch' , 'false' ) )
31
- . then ( ( ) => expectFileToExist ( path . join ( homedir ( ) , '.angular-config.json' ) ) )
32
- . then ( ( ) => deleteFile ( path . join ( homedir ( ) , '.angular-config.json' ) ) ) ;
8
+ export default async function ( ) {
9
+ await expectToFail ( ( ) => ng (
10
+ 'config' ,
11
+ '--global' ,
12
+ 'schematics.@schematics/angular.component.inlineStyle' ,
13
+ ) ) ;
14
+
15
+ await ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' , 'false' ) ;
16
+ let output = await ng (
17
+ 'config' ,
18
+ '--global' ,
19
+ 'schematics.@schematics/angular.component.inlineStyle' ,
20
+ ) ;
21
+ if ( ! output . stdout . match ( / f a l s e \n ? / ) ) {
22
+ throw new Error ( `Expected "false", received "${ JSON . stringify ( output . stdout ) } ".` ) ;
23
+ }
24
+
25
+ // This test requires schema querying capabilities
26
+ // .then(() => expectToFail(() => {
27
+ // return ng('config', '--global', 'schematics.@schematics/angular.component.inlineStyle', 'INVALID_BOOLEAN');
28
+ // }))
29
+
30
+ const cwd = process . cwd ( ) ;
31
+ process . chdir ( '/' ) ;
32
+ try {
33
+ await ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' , 'true' ) ;
34
+ } finally {
35
+ process . chdir ( cwd ) ;
36
+ }
37
+
38
+ output = await ng ( 'config' , '--global' , 'schematics.@schematics/angular.component.inlineStyle' ) ;
39
+ if ( ! output . stdout . match ( / t r u e \n ? / ) ) {
40
+ throw new Error ( `Expected "true", received "${ JSON . stringify ( output . stdout ) } ".` ) ;
41
+ }
42
+
43
+ await expectToFail ( ( ) => ng ( 'config' , '--global' , 'cli.warnings.notreal' , 'true' ) ) ;
44
+
45
+ await ng ( 'config' , '--global' , 'cli.warnings.versionMismatch' , 'false' ) ;
46
+ await expectFileToExist ( path . join ( homedir ( ) , '.angular-config.json' ) ) ;
47
+ await deleteFile ( path . join ( homedir ( ) , '.angular-config.json' ) ) ;
33
48
}
0 commit comments