Skip to content

Commit 6e79da0

Browse files
committed
refactoring(migrations): unit test signal migration adjustment
Move unit test from spec file to golden test
1 parent 32f86d3 commit 6e79da0

4 files changed

Lines changed: 32 additions & 24 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// tslint:disable
2+
3+
import {Input} from '@angular/core';
4+
5+
export class TestComponent {
6+
@Input() fnDisplay = (item: any) => item;
7+
@Input() fnEquals = (a: any, b: any) => this.fnDisplay(a) === this.fnDisplay(b);
8+
}

packages/core/schematics/migrations/signal-migration/test/golden.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,18 @@ import {Component, input} from '@angular/core';
749749
export class InlineTmpl {
750750
readonly justify = input<'start' | 'end'>('end');
751751
}
752+
@@@@@@ input_function_that_reference_this.ts @@@@@@
753+
754+
// tslint:disable
755+
756+
import {input} from '@angular/core';
757+
758+
export class TestComponent {
759+
760+
readonly fnDisplay = input((item: any) => item);
761+
@Input() fnEquals = (a: any, b: any) => this.fnDisplay()(a) === this.fnDisplay()(b);
762+
763+
}
752764
@@@@@@ jit_true_component_external_tmpl.html @@@@@@
753765

754766
{{test()}}

packages/core/schematics/migrations/signal-migration/test/golden_best_effort.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,18 @@ import {Component, input} from '@angular/core';
719719
export class InlineTmpl {
720720
readonly justify = input<'start' | 'end'>('end');
721721
}
722+
@@@@@@ input_function_that_reference_this.ts @@@@@@
723+
724+
// tslint:disable
725+
726+
import {input} from '@angular/core';
727+
728+
export class TestComponent {
729+
730+
readonly fnDisplay = input((item: any) => item);
731+
@Input() fnEquals = (a: any, b: any) => this.fnDisplay()(a) === this.fnDisplay()(b);
732+
733+
}
722734
@@@@@@ jit_true_component_external_tmpl.html @@@@@@
723735

724736
{{test()}}

packages/core/schematics/test/signal_input_migration_spec.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,6 @@ describe('signal input migration', () => {
128128
expect(messages).toContain(` -> Migrated 1/2 inputs.`);
129129
});
130130

131-
it('should not migrate input functions that reference this', async () => {
132-
const source = `
133-
import {Component, Input} from '@angular/core';
134-
135-
@Component({})
136-
export class TestComponent {
137-
138-
@Input() fnDisplay = (item: any) => item;
139-
@Input() fnEquals = (a: any, b: any) => this.fnDisplay(a) === this.fnDisplay(b);
140-
141-
}
142-
`;
143-
144-
writeFile('/index.ts', source);
145-
await runMigration();
146-
const content = tree.readContent('/index.ts');
147-
148-
// Verify the simple function was migrated
149-
expect(content).toContain('readonly fnDisplay = input((item: any) => item);');
150-
expect(content).toContain(
151-
'@Input() fnEquals = (a: any, b: any) => this.fnDisplay()(a) === this.fnDisplay()(b);',
152-
);
153-
});
154-
155131
it('should report correct statistics with best effort mode', async () => {
156132
writeFile(`node_modules/@tsconfig/strictest/tsconfig.json`, `{}`);
157133
writeFile(

0 commit comments

Comments
 (0)