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+ [ 'standalone' as never /* TODO: remove after upgrade to a14 */ ] :
23+ true ,
24+ schemas : [ NO_ERRORS_SCHEMA ] , // TODO: remove after upgrade to a16
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 ( ( ) => MockBuilder ( TargetComponent ) ) ;
36+
37+ it ( 'issue-10942' , ( ) => {
38+ const fixture = TestBed . createComponent ( TargetComponent ) ;
39+ fixture . detectChanges ( ) ;
40+ ngMocks . output ( 'app-signal' , 'modelChange' ) . emit ( 'test-new' ) ;
41+ fixture . detectChanges ( ) ;
42+ expect ( ngMocks . find ( 'h1' ) . nativeElement . innerHTML ) . toEqual (
43+ 'test-new' ,
44+ ) ;
45+ } ) ;
46+ } ) ;
You can’t perform that action at this time.
0 commit comments