File tree Expand file tree Collapse file tree
libs/ng-mocks/src/lib/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ export default function (param: DirectiveIo): DirectiveIoParsed {
88 return { name } ;
99 }
1010
11+ if ( name + 'Change' === alias ) {
12+ return { name : alias } ; // model output
13+ }
14+
1115 return { name, alias } ;
1216 }
1317
Original file line number Diff line number Diff line change 1+ import {
2+ Component ,
3+ model ,
4+ NO_ERRORS_SCHEMA ,
5+ signal ,
6+ } from '@angular/core' ;
7+ import { TestBed } from '@angular/core/testing' ;
8+
9+ import { MockBuilder , ngMocks } from 'ng-mocks' ;
10+
11+ @Component ( {
12+ selector : 'app-signal' ,
13+ [ 'standalone' as never /* TODO: remove after upgrade to a14 */ ] :
14+ true ,
15+ template : `` ,
16+ } )
17+ export class SignalComponent {
18+ model = model ( '' ) ;
19+ }
20+ @Component ( {
21+ imports : [ SignalComponent ] ,
22+ selector : 'app-target' ,
23+ [ 'standalone' as never /* TODO: remove after upgrade to a14 */ ] :
24+ true ,
25+ template : `
26+ <h1>{{ title() }}</h1>
27+ <app-signal [(model)]="title"></app-signal>
28+ ` ,
29+ } )
30+ export class TargetComponent {
31+ title = signal ( 'test-default' ) ;
32+ }
33+
34+ describe ( 'issue-10942' , ( ) => {
35+ beforeEach ( ( ) =>
36+ MockBuilder ( TargetComponent ) . beforeCompileComponents ( testBed =>
37+ testBed . configureTestingModule ( {
38+ schemas : [ NO_ERRORS_SCHEMA ] , // remove it after upgrade to a16
39+ } ) ,
40+ ) ,
41+ ) ;
42+
43+ it ( 'issue-10942' , ( ) => {
44+ const fixture = TestBed . createComponent ( TargetComponent ) ;
45+ fixture . detectChanges ( ) ;
46+ ngMocks . output ( 'app-signal' , 'modelChange' ) . emit ( 'test-new' ) ;
47+ fixture . detectChanges ( ) ;
48+ expect ( ngMocks . find ( 'h1' ) . nativeElement . innerHTML ) . toEqual (
49+ 'test-new' ,
50+ ) ;
51+ } ) ;
52+ } ) ;
You can’t perform that action at this time.
0 commit comments