@@ -31,17 +31,17 @@ describe('Convert relative imports to mapped imports', () => {
3131 join ( __dirname , '../collection.json' )
3232 ) ;
3333
34- it ( 'should convert the relative imports in a newly generated file' , ( ) => {
34+ it ( 'should convert the relative imports in a newly generated file' , async ( ) => {
3535 let appTree = createTestProject ( projSetup ) ;
3636
3737 appTree . create ( aboutModulePath , relativeImportContent ) ;
38- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
38+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
3939 const actual = getFileContent ( appTree , aboutModulePath ) ;
4040
4141 expect ( actual ) . toEqual ( fixedImportContent ) ;
4242 } ) ;
4343
44- it ( 'should convert the relative imports in a modified file' , ( ) => {
44+ it ( 'should convert the relative imports in a modified file' , async ( ) => {
4545 const existingContent = `
4646 import { AboutComponent } from '${ importPrefix } /about/about.component';
4747 ` ;
@@ -60,85 +60,85 @@ describe('Convert relative imports to mapped imports', () => {
6060 } ] ) ;
6161
6262 appTree . overwrite ( aboutModulePath , modifiedContent ) ;
63- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
63+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
6464 const actual = getFileContent ( appTree , aboutModulePath ) ;
6565
6666 expect ( actual ) . toEqual ( expected ) ;
6767 } ) ;
6868
69- it ( 'should convert the relative imports in a created and then renamed file' , ( ) => {
69+ it ( 'should convert the relative imports in a created and then renamed file' , async ( ) => {
7070 let appTree = createTestProject ( projSetup ) ;
7171
7272 const renamedFilePath = aboutModulePath . replace ( ".ts" , ".tns.ts" ) ;
7373
7474 appTree . create ( aboutModulePath , relativeImportContent ) ;
7575 appTree . rename ( aboutModulePath , renamedFilePath ) ;
7676
77- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
77+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
7878 const actual = getFileContent ( appTree , renamedFilePath ) ;
7979
8080 expect ( actual ) . toEqual ( fixedImportContent ) ;
8181 } ) ;
8282
83- it ( 'should not modify files that weren\'t modified' , ( ) => {
83+ it ( 'should not modify files that weren\'t modified' , async ( ) => {
8484 let appTree = createTestProject ( projSetup , [ {
8585 path : aboutModulePath ,
8686 content : relativeImportContent
8787 } ] ) ;
8888
89- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
89+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
9090 const actual = getFileContent ( appTree , aboutModulePath ) ;
9191
9292 expect ( actual ) . toEqual ( relativeImportContent ) ;
9393 } ) ;
9494
95- it ( 'should not modify files with extension other than .ts' , ( ) => {
95+ it ( 'should not modify files with extension other than .ts' , async ( ) => {
9696 let appTree = createTestProject ( projSetup ) ;
9797
9898 const generatedFilePath = `${ sourceDirectory } /about/about.component.tsx` ;
9999
100100 appTree . create ( generatedFilePath , relativeImportContent ) ;
101- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
101+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
102102 const actual = getFileContent ( appTree , generatedFilePath ) ;
103103
104104 expect ( actual ) . toEqual ( relativeImportContent ) ;
105105 } ) ;
106106
107- it ( 'should not modify files specified as ignored in the invocation options' , ( ) => {
107+ it ( 'should not modify files specified as ignored in the invocation options' , async ( ) => {
108108 let appTree = createTestProject ( projSetup ) ;
109109
110110 appTree . create ( aboutModulePath , relativeImportContent ) ;
111111
112112 const options : ConvertRelativeImportsOptions = { ...defaultOptions , filesToIgnore : [ aboutModulePath ] } ;
113- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , options , appTree ) ;
113+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , options , appTree ) . toPromise ( ) ;
114114 const actual = getFileContent ( appTree , aboutModulePath ) ;
115115
116116 expect ( actual ) . toEqual ( relativeImportContent ) ;
117117 } ) ;
118118
119- it ( 'should not modify files that are deleted by previous rules' , ( ) => {
119+ it ( 'should not modify files that are deleted by previous rules' , async ( ) => {
120120 let appTree = createTestProject ( projSetup , [ {
121121 path : aboutModulePath ,
122122 content : relativeImportContent
123123 } ] ) ;
124124
125125 appTree . delete ( aboutModulePath ) ;
126- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
126+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
127127
128128 expect ( appTree . get ( aboutModulePath ) ) . toBeNull ( ) ;
129129 } ) ;
130130
131- it ( 'should not modify files that were created and then deleted by previous rules' , ( ) => {
131+ it ( 'should not modify files that were created and then deleted by previous rules' , async ( ) => {
132132 let appTree = createTestProject ( projSetup ) ;
133133
134134 appTree . create ( aboutModulePath , relativeImportContent ) ;
135135 appTree . delete ( aboutModulePath ) ;
136- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
136+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
137137
138138 expect ( appTree . get ( aboutModulePath ) ) . toBeNull ( ) ;
139139 } ) ;
140140
141- it ( 'should not modify files that were modified and then deleted by previous rules' , ( ) => {
141+ it ( 'should not modify files that were modified and then deleted by previous rules' , async ( ) => {
142142
143143 let appTree = createTestProject ( projSetup , [ {
144144 path : aboutModulePath ,
@@ -147,7 +147,7 @@ describe('Convert relative imports to mapped imports', () => {
147147
148148 appTree . overwrite ( aboutModulePath , relativeImportContent + '\nconsole.log(\'modified\');\n' ) ;
149149 appTree . delete ( aboutModulePath ) ;
150- appTree = schematicRunner . runSchematic ( 'convert-relative-imports' , defaultOptions , appTree ) ;
150+ appTree = await schematicRunner . runSchematicAsync ( 'convert-relative-imports' , defaultOptions , appTree ) . toPromise ( ) ;
151151
152152 expect ( appTree . get ( aboutModulePath ) ) . toBeNull ( ) ;
153153 } ) ;
0 commit comments