@@ -36,6 +36,7 @@ import {
3636} from '../../src/core' ;
3737import { stringifyForError } from '../../src/render3/util/stringify_utils' ;
3838import { TestBed } from '../../testing' ;
39+ import { ChangeDetectionStrategy } from '@angular/compiler' ;
3940
4041describe ( 'createComponent' , ( ) => {
4142 it ( 'should create an instance of a standalone component' , ( ) => {
@@ -1111,6 +1112,34 @@ describe('createComponent', () => {
11111112 / C a n n o t c a l l ` s e t I n p u t ` o n a c o m p o n e n t t h a t i s u s i n g t h e ` i n p u t B i n d i n g ` o r ` t w o W a y B i n d i n g ` f u n c t i o n s / ,
11121113 ) ;
11131114 } ) ;
1115+
1116+ it ( 'should update view of component set with the onPush strategy after input change' , ( ) => {
1117+ @Component ( {
1118+ standalone : true ,
1119+ changeDetection : ChangeDetectionStrategy . OnPush ,
1120+ template : 'Value: {{ value }}' ,
1121+ } )
1122+ class DisplayOnPushComponent {
1123+ @Input ( ) value : number = - 1 ;
1124+ }
1125+
1126+ const hostElement = document . createElement ( 'div' ) ;
1127+ const environmentInjector = TestBed . inject ( EnvironmentInjector ) ;
1128+ const valueSignal = signal ( 10 ) ;
1129+
1130+ const componentRef = createComponent ( DisplayOnPushComponent , {
1131+ hostElement,
1132+ environmentInjector,
1133+ bindings : [ inputBinding ( 'value' , valueSignal ) ] ,
1134+ } ) ;
1135+
1136+ componentRef . changeDetectorRef . detectChanges ( ) ;
1137+ expect ( hostElement . textContent ) . toBe ( 'Value: 10' ) ;
1138+
1139+ valueSignal . set ( 20 ) ;
1140+ componentRef . changeDetectorRef . detectChanges ( ) ;
1141+ expect ( hostElement . textContent ) . toBe ( 'Value: 20' ) ;
1142+ } ) ;
11141143 } ) ;
11151144
11161145 describe ( 'root component outputs' , ( ) => {
0 commit comments