@@ -44,54 +44,61 @@ describe('Class Schematic', () => {
44
44
appTree = schematicRunner . runSchematic ( 'application' , appOptions , appTree ) ;
45
45
} ) ;
46
46
47
- it ( 'should create just the class file' , ( ) => {
48
- const tree = schematicRunner . runSchematic ( 'class' , defaultOptions , appTree ) ;
47
+ it ( 'should create just the class file' , async ( ) => {
48
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , defaultOptions , appTree )
49
+ . toPromise ( ) ;
49
50
expect ( tree . files ) . toContain ( '/projects/bar/src/app/foo.ts' ) ;
50
51
expect ( tree . files ) . not . toContain ( '/projects/bar/src/app/foo.spec.ts' ) ;
51
52
} ) ;
52
53
53
- it ( 'should create the class and spec file' , ( ) => {
54
+ it ( 'should create the class and spec file' , async ( ) => {
54
55
const options = {
55
56
...defaultOptions ,
56
57
spec : true ,
57
58
} ;
58
- const tree = schematicRunner . runSchematic ( 'class' , options , appTree ) ;
59
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , options , appTree )
60
+ . toPromise ( ) ;
59
61
expect ( tree . files ) . toContain ( '/projects/bar/src/app/foo.ts' ) ;
60
62
expect ( tree . files ) . toContain ( '/projects/bar/src/app/foo.spec.ts' ) ;
61
63
} ) ;
62
64
63
- it ( 'should create an class named "Foo"' , ( ) => {
64
- const tree = schematicRunner . runSchematic ( 'class' , defaultOptions , appTree ) ;
65
+ it ( 'should create an class named "Foo"' , async ( ) => {
66
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , defaultOptions , appTree )
67
+ . toPromise ( ) ;
65
68
const fileContent = tree . readContent ( '/projects/bar/src/app/foo.ts' ) ;
66
69
expect ( fileContent ) . toMatch ( / e x p o r t c l a s s F o o / ) ;
67
70
} ) ;
68
71
69
- it ( 'should put type in the file name' , ( ) => {
72
+ it ( 'should put type in the file name' , async ( ) => {
70
73
const options = { ...defaultOptions , type : 'model' } ;
71
74
72
- const tree = schematicRunner . runSchematic ( 'class' , options , appTree ) ;
75
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , options , appTree )
76
+ . toPromise ( ) ;
73
77
expect ( tree . files ) . toContain ( '/projects/bar/src/app/foo.model.ts' ) ;
74
78
} ) ;
75
79
76
- it ( 'should split the name to name & type with split on "."' , ( ) => {
80
+ it ( 'should split the name to name & type with split on "."' , async ( ) => {
77
81
const options = { ...defaultOptions , name : 'foo.model' } ;
78
- const tree = schematicRunner . runSchematic ( 'class' , options , appTree ) ;
82
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , options , appTree )
83
+ . toPromise ( ) ;
79
84
const classPath = '/projects/bar/src/app/foo.model.ts' ;
80
85
const content = tree . readContent ( classPath ) ;
81
86
expect ( content ) . toMatch ( / e x p o r t c l a s s F o o / ) ;
82
87
} ) ;
83
88
84
- it ( 'should respect the path option' , ( ) => {
89
+ it ( 'should respect the path option' , async ( ) => {
85
90
const options = { ...defaultOptions , path : 'zzz' } ;
86
- const tree = schematicRunner . runSchematic ( 'class' , options , appTree ) ;
91
+ const tree = await schematicRunner . runSchematicAsync ( 'class' , options , appTree )
92
+ . toPromise ( ) ;
87
93
expect ( tree . files ) . toContain ( '/zzz/foo.ts' ) ;
88
94
} ) ;
89
95
90
- it ( 'should respect the sourceRoot value' , ( ) => {
96
+ it ( 'should respect the sourceRoot value' , async ( ) => {
91
97
const config = JSON . parse ( appTree . readContent ( '/angular.json' ) ) ;
92
98
config . projects . bar . sourceRoot = 'projects/bar/custom' ;
93
99
appTree . overwrite ( '/angular.json' , JSON . stringify ( config , null , 2 ) ) ;
94
- appTree = schematicRunner . runSchematic ( 'class' , defaultOptions , appTree ) ;
100
+ appTree = await schematicRunner . runSchematicAsync ( 'class' , defaultOptions , appTree )
101
+ . toPromise ( ) ;
95
102
expect ( appTree . files ) . toContain ( '/projects/bar/custom/app/foo.ts' ) ;
96
103
} ) ;
97
104
} ) ;
0 commit comments