Skip to content

Commit 9ce839f

Browse files
committed
test(migrations): add test for statistic collection tsurge (angular#58019)
Adds a test for statistic testing of Tsurge PR Close angular#58019
1 parent 273444a commit 9ce839f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

packages/core/schematics/utils/tsurge/test/output_migration.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,40 @@ describe('output migration', () => {
6767

6868
expect(fs.readFile(absoluteFrom('/app.component.ts'))).not.toContain('TODO');
6969
});
70+
71+
it('should compute statistics', async () => {
72+
const migration = new OutputMigration();
73+
const {getStatistics} = await runTsurgeMigration(migration, [
74+
{
75+
name: absoluteFrom('/app.component.ts'),
76+
isProgramRootFile: true,
77+
contents: `
78+
import {Output, Component, EventEmitter} from '@angular/core';
79+
80+
@Component()
81+
export class AppComponent {
82+
@Output() clicked = new EventEmitter<void>();
83+
@Output() canBeMigrated = new EventEmitter<void>();
84+
}
85+
`,
86+
},
87+
{
88+
name: absoluteFrom('/other.component.ts'),
89+
isProgramRootFile: true,
90+
contents: `
91+
import {AppComponent} from './app.component';
92+
93+
const cmp: AppComponent = null!;
94+
cmp.clicked.pipe().subscribe();
95+
`,
96+
},
97+
]);
98+
99+
expect(await getStatistics()).toEqual({
100+
counters: {
101+
allOutputs: 2,
102+
migratedOutputs: 1,
103+
},
104+
});
105+
});
70106
});

0 commit comments

Comments
 (0)