1- import { Component , signal , viewChild , ViewContainerRef } from '@angular/core' ;
1+ import { Component , inputBinding , viewChild , ViewContainerRef } from '@angular/core' ;
2+ import { TestBed } from '@angular/core/testing' ;
23import { faUser } from '@fortawesome/free-solid-svg-icons' ;
3- import { faDummy , initTest , queryByCss } from '../../testing/helpers' ;
4+ import { faDummy , queryByCss } from '../../testing/helpers' ;
45import { FaDuotoneIconComponent } from './duotone-icon.component' ;
56
67describe ( 'FaDuotoneIconComponent' , ( ) => {
78 it ( 'should render the duotone icon' , ( ) => {
8- @Component ( {
9- selector : 'fa-host' ,
10- standalone : false ,
11- template : '<fa-duotone-icon [icon]="faDummy()" />' ,
12- } )
13- class HostComponent {
14- faDummy = signal ( faDummy ) ;
15- }
16-
17- const fixture = initTest ( HostComponent ) ;
9+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
10+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) ] ,
11+ } ) ;
1812 fixture . detectChanges ( ) ;
1913 expect ( queryByCss ( fixture , 'svg' ) ) . toBeTruthy ( ) ;
2014 } ) ;
2115
2216 it ( 'should allow to swap opacity of the layers' , ( ) => {
23- @Component ( {
24- selector : 'fa-host' ,
25- standalone : false ,
26- template : '<fa-duotone-icon [icon]="faDummy()" [swapOpacity]="true" />' ,
27- } )
28- class HostComponent {
29- faDummy = signal ( faDummy ) ;
30- }
31-
32- const fixture = initTest ( HostComponent ) ;
17+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
18+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) , inputBinding ( 'swapOpacity' , ( ) => true ) ] ,
19+ } ) ;
3320 fixture . detectChanges ( ) ;
3421 expect ( queryByCss ( fixture , 'svg' ) . classList . contains ( 'fa-swap-opacity' ) ) . toBeTruthy ( ) ;
3522 } ) ;
3623
3724 it ( 'should allow to customize opacity of the primary layer' , ( ) => {
38- @Component ( {
39- selector : 'fa-host' ,
40- standalone : false ,
41- template : '<fa-duotone-icon [icon]="faDummy()" [primaryOpacity]="0.1" />' ,
42- } )
43- class HostComponent {
44- faDummy = signal ( faDummy ) ;
45- }
46-
47- const fixture = initTest ( HostComponent ) ;
25+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
26+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) , inputBinding ( 'primaryOpacity' , ( ) => 0.1 ) ] ,
27+ } ) ;
4828 fixture . detectChanges ( ) ;
4929 expect ( queryByCss ( fixture , 'svg' ) . style . getPropertyValue ( '--fa-primary-opacity' ) ) . toBe ( '0.1' ) ;
5030 } ) ;
5131
5232 it ( 'should allow to customize opacity of the secondary layer' , ( ) => {
53- @Component ( {
54- selector : 'fa-host' ,
55- standalone : false ,
56- template : '<fa-duotone-icon [icon]="faDummy()" [secondaryOpacity]="0.9" />' ,
57- } )
58- class HostComponent {
59- faDummy = signal ( faDummy ) ;
60- }
61-
62- const fixture = initTest ( HostComponent ) ;
33+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
34+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) , inputBinding ( 'secondaryOpacity' , ( ) => 0.9 ) ] ,
35+ } ) ;
6336 fixture . detectChanges ( ) ;
6437 expect ( queryByCss ( fixture , 'svg' ) . style . getPropertyValue ( '--fa-secondary-opacity' ) ) . toBe ( '0.9' ) ;
6538 } ) ;
6639
6740 it ( 'should allow to customize color of the primary layer' , ( ) => {
68- @Component ( {
69- selector : 'fa-host' ,
70- standalone : false ,
71- template : '<fa-duotone-icon [icon]="faDummy()" primaryColor="red" />' ,
72- } )
73- class HostComponent {
74- faDummy = signal ( faDummy ) ;
75- }
76-
77- const fixture = initTest ( HostComponent ) ;
41+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
42+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) , inputBinding ( 'primaryColor' , ( ) => 'red' ) ] ,
43+ } ) ;
7844 fixture . detectChanges ( ) ;
7945 expect ( queryByCss ( fixture , 'svg' ) . style . getPropertyValue ( '--fa-primary-color' ) ) . toBe ( 'red' ) ;
8046 } ) ;
8147
8248 it ( 'should allow to customize color of the secondary layer' , ( ) => {
83- @Component ( {
84- selector : 'fa-host' ,
85- standalone : false ,
86- template : '<fa-duotone-icon [icon]="faDummy()" secondaryColor="red" />' ,
87- } )
88- class HostComponent {
89- faDummy = signal ( faDummy ) ;
90- }
91-
92- const fixture = initTest ( HostComponent ) ;
49+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , {
50+ bindings : [ inputBinding ( 'icon' , ( ) => faDummy ) , inputBinding ( 'secondaryColor' , ( ) => 'red' ) ] ,
51+ } ) ;
9352 fixture . detectChanges ( ) ;
9453 expect ( queryByCss ( fixture , 'svg' ) . style . getPropertyValue ( '--fa-secondary-color' ) ) . toBe ( 'red' ) ;
9554 } ) ;
9655
9756 it ( 'should throw if specified icon is not a Duotone icon' , ( ) => {
98- @Component ( {
99- selector : 'fa-host' ,
100- standalone : false ,
101- template : '<fa-duotone-icon [icon]="faUser()" />' ,
102- } )
103- class HostComponent {
104- faUser = signal ( faUser ) ;
105- }
106-
107- const fixture = initTest ( HostComponent ) ;
57+ const fixture = TestBed . createComponent ( FaDuotoneIconComponent , { bindings : [ inputBinding ( 'icon' , ( ) => faUser ) ] } ) ;
10858 expect ( ( ) => fixture . detectChanges ( ) ) . toThrow (
10959 new Error (
11060 'The specified icon does not appear to be a Duotone icon. ' +
@@ -117,7 +67,6 @@ describe('FaDuotoneIconComponent', () => {
11767 it ( 'should be able to create component dynamically' , ( ) => {
11868 @Component ( {
11969 selector : 'fa-host' ,
120- standalone : false ,
12170 template : '<ng-container #host></ng-container>' ,
12271 } )
12372 class HostComponent {
@@ -129,7 +78,7 @@ describe('FaDuotoneIconComponent', () => {
12978 }
13079 }
13180
132- const fixture = initTest ( HostComponent ) ;
81+ const fixture = TestBed . createComponent ( HostComponent ) ;
13382 fixture . detectChanges ( ) ;
13483 expect ( queryByCss ( fixture , 'svg' ) ) . toBeFalsy ( ) ;
13584
0 commit comments