7
7
*/
8
8
9
9
import { RElement } from '@angular/core/src/render3/interfaces/renderer_dom' ;
10
- import { Injector , NgModuleRef , RendererType2 , ViewEncapsulation } from '../../src/core' ;
10
+
11
+ import { Component , Injector , Input , NgModuleRef , Output , RendererType2 , ViewEncapsulation } from '../../src/core' ;
11
12
import { ComponentFactory } from '../../src/linker/component_factory' ;
12
13
import { RendererFactory2 } from '../../src/render/api' ;
13
14
import { injectComponentFactoryResolver } from '../../src/render3/component_ref' ;
14
- import { AttributeMarker , ɵɵdefineComponent } from '../../src/render3/index' ;
15
15
import { domRendererFactory3 , Renderer3 , RendererFactory3 } from '../../src/render3/interfaces/renderer' ;
16
16
import { Sanitizer } from '../../src/sanitization/sanitizer' ;
17
17
@@ -20,15 +20,12 @@ describe('ComponentFactory', () => {
20
20
21
21
describe ( 'constructor()' , ( ) => {
22
22
it ( 'should correctly populate default properties' , ( ) => {
23
+ @Component ( {
24
+ selector : 'test[foo], bar' ,
25
+ standalone : true ,
26
+ template : '' ,
27
+ } )
23
28
class TestComponent {
24
- static ɵfac = ( ) => new TestComponent ( ) ;
25
- static ɵcmp = ɵɵdefineComponent ( {
26
- type : TestComponent ,
27
- selectors : [ [ 'test' , 'foo' , '' ] , [ 'bar' ] ] ,
28
- decls : 0 ,
29
- vars : 0 ,
30
- template : ( ) => undefined ,
31
- } ) ;
32
29
}
33
30
34
31
const cf = cfr . resolveComponentFactory ( TestComponent ) ;
@@ -41,25 +38,23 @@ describe('ComponentFactory', () => {
41
38
} ) ;
42
39
43
40
it ( 'should correctly populate defined properties' , ( ) => {
41
+ @Component ( {
42
+ selector : 'test[foo], bar' ,
43
+ standalone : true ,
44
+ template : `
45
+ <ng-content></ng-content>
46
+ <ng-content select="a"></ng-content>
47
+ <ng-content select="b"></ng-content>
48
+ ` ,
49
+ } )
44
50
class TestComponent {
45
- static ɵfac = ( ) => new TestComponent ( ) ;
46
- static ɵcmp = ɵɵdefineComponent ( {
47
- type : TestComponent ,
48
- encapsulation : ViewEncapsulation . None ,
49
- selectors : [ [ 'test' , 'foo' , '' ] , [ 'bar' ] ] ,
50
- decls : 0 ,
51
- vars : 0 ,
52
- template : ( ) => undefined ,
53
- ngContentSelectors : [ '*' , 'a' , 'b' ] ,
54
- inputs : {
55
- in1 : 'in1' ,
56
- in2 : [ 'input-attr-2' , 'in2' ] ,
57
- } ,
58
- outputs : {
59
- out1 : 'out1' ,
60
- out2 : 'output-attr-2' ,
61
- } ,
62
- } ) ;
51
+ @Input ( ) in1 : unknown ;
52
+
53
+ @Input ( 'input-attr-2' ) in2 : unknown ;
54
+
55
+ @Output ( ) out1 : unknown ;
56
+
57
+ @Output ( 'output-attr-2' ) out2 : unknown ;
63
58
}
64
59
65
60
const cf = cfr . resolveComponentFactory ( TestComponent ) ;
@@ -89,17 +84,15 @@ describe('ComponentFactory', () => {
89
84
jasmine . createSpy ( 'RendererFactory2#createRenderer' ) . and . returnValue ( document ) ,
90
85
createRenderer3Spy = spyOn ( domRendererFactory3 , 'createRenderer' ) . and . callThrough ( ) ;
91
86
87
+ @Component ( {
88
+ selector : 'test' ,
89
+ template : '...' ,
90
+ host : {
91
+ 'class' : 'HOST_COMPONENT' ,
92
+ } ,
93
+ encapsulation : ViewEncapsulation . None
94
+ } )
92
95
class TestComponent {
93
- static ɵfac = ( ) => new TestComponent ( ) ;
94
- static ɵcmp = ɵɵdefineComponent ( {
95
- type : TestComponent ,
96
- encapsulation : ViewEncapsulation . None ,
97
- selectors : [ [ 'test' ] ] ,
98
- decls : 0 ,
99
- vars : 0 ,
100
- template : ( ) => undefined ,
101
- hostAttrs : [ AttributeMarker . Classes , 'HOST_COMPONENT' ]
102
- } ) ;
103
96
}
104
97
105
98
cf = cfr . resolveComponentFactory ( TestComponent ) ;
0 commit comments