@@ -38,6 +38,7 @@ describe('ComponentParser', () => {
3838 selector : 'my-test-comp' ,
3939 standalone : false ,
4040 cva : false ,
41+ onPush : false ,
4142 template : inlineTemplate ,
4243 styles : [ styles ] ,
4344 inputs : [
@@ -47,6 +48,7 @@ describe('ComponentParser', () => {
4748 type : 'string' ,
4849 initializer : undefined ,
4950 field : '@Input() foo: string' ,
51+ jsDoc : undefined ,
5052 } ,
5153 ] ,
5254 outputs : [
@@ -56,6 +58,7 @@ describe('ComponentParser', () => {
5658 type : undefined ,
5759 initializer : 'new EventEmitter()' ,
5860 field : '@Output() bar = new EventEmitter()' ,
61+ jsDoc : undefined ,
5962 } ,
6063 ] ,
6164 implementation,
@@ -103,6 +106,7 @@ describe('ComponentParser', () => {
103106 selector : 'my-test-comp' ,
104107 standalone : true ,
105108 cva : false ,
109+ onPush : false ,
106110 template : inlineTemplate ,
107111 styles : [ styles ] ,
108112 inputs : [
@@ -112,6 +116,7 @@ describe('ComponentParser', () => {
112116 type : 'string' ,
113117 initializer : undefined ,
114118 field : '@Input() foo: string' ,
119+ jsDoc : undefined ,
115120 } ,
116121 ] ,
117122 outputs : [
@@ -121,6 +126,7 @@ describe('ComponentParser', () => {
121126 type : undefined ,
122127 initializer : 'new EventEmitter()' ,
123128 field : '@Output() bar = new EventEmitter()' ,
129+ jsDoc : undefined ,
124130 } ,
125131 ] ,
126132 implementation,
@@ -195,4 +201,35 @@ describe('ComponentParser', () => {
195201
196202 expect ( parseComponent ( ast , 'foo.component.ts' ) . template ) . toBe ( '' ) ;
197203 } ) ;
204+
205+ it ( 'should detect OnPush change detection strategy' , ( ) => {
206+ const ast = tsquery . ast ( `
207+ @Component({
208+ selector: 'my-test-comp',
209+ template: '<h1>Foo</h1>',
210+ styles: [],
211+ changeDetection: ChangeDetectionStrategy.OnPush
212+ })
213+ export class MyTestComponent {}
214+ ` ) ;
215+
216+ jest . spyOn ( fs , 'readFileSync' ) . mockReturnValue ( '' ) ;
217+
218+ expect ( parseComponent ( ast , 'foo.component.ts' ) . onPush ) . toBeTruthy ( ) ;
219+ } ) ;
220+
221+ it ( 'should default to false for change detection strategy when not specified' , ( ) => {
222+ const ast = tsquery . ast ( `
223+ @Component({
224+ selector: 'my-test-comp',
225+ template: '<h1>Foo</h1>',
226+ styles: []
227+ })
228+ export class MyTestComponent {}
229+ ` ) ;
230+
231+ jest . spyOn ( fs , 'readFileSync' ) . mockReturnValue ( '' ) ;
232+
233+ expect ( parseComponent ( ast , 'foo.component.ts' ) . onPush ) . toBeFalsy ( ) ;
234+ } ) ;
198235} ) ;
0 commit comments