1- import { Component , Type } from '@angular/core' ;
1+ import { Component , Type , ElementRef } from '@angular/core' ;
22import { ComponentFixture , TestBed } from '@angular/core/testing' ;
33import { faUser , faMobile } from '@fortawesome/free-solid-svg-icons' ;
4-
4+ import { By } from '@angular/platform-browser' ;
55import { FaIconComponent } from '../icon/icon.component' ;
66import { FaLayersComponent } from './layers.component' ;
77import { FaLayersTextComponent } from './layers-text.component' ;
@@ -17,6 +17,10 @@ function svgLayers(fixture: ComponentFixture<any>): SVGElement {
1717 return fixture . debugElement . nativeElement . querySelector ( 'svg' ) ;
1818}
1919
20+ function queryByCss ( fixture : ComponentFixture < any > , className : string ) : ElementRef {
21+ return fixture . debugElement . query ( By . css ( className ) ) ;
22+ }
23+
2024describe ( 'FaLayersCompoennt' , ( ) => {
2125 it ( 'should render layers icon' , ( ) => {
2226 @Component ( {
@@ -37,4 +41,65 @@ describe('FaLayersCompoennt', () => {
3741 fixture . detectChanges ( ) ;
3842 expect ( svgLayers ( fixture ) ) . toBeTruthy ( ) ;
3943 } ) ;
44+
45+ it ( 'should include size class' , ( ) => {
46+ @Component ( {
47+ selector : 'fa-host' ,
48+ template : `
49+ <fa-layers size="2x">
50+ <fa-icon [icon]="faUser"></fa-icon>
51+ <fa-icon [icon]="faMobile"></fa-icon>
52+ <fa-layers-text [content]="'User with mobile'" [styles]="{ color: 'Tomato' }"></fa-layers-text>
53+ </fa-layers>`
54+ } )
55+ class HostComponent {
56+ faUser = faUser ;
57+ faMobile = faMobile ;
58+ }
59+
60+ const fixture = initTest ( HostComponent ) ;
61+ fixture . detectChanges ( ) ;
62+ expect ( queryByCss ( fixture , '.fa-2x' ) ) . toBeTruthy ( ) ;
63+ } ) ;
64+
65+ it ( 'should include fixed width' , ( ) => {
66+ @Component ( {
67+ selector : 'fa-host' ,
68+ template : `
69+ <fa-layers [fixedWidth]="true">
70+ <fa-icon [icon]="faUser"></fa-icon>
71+ <fa-icon [icon]="faMobile"></fa-icon>
72+ <fa-layers-text [content]="'User with mobile'" [styles]="{ color: 'Tomato' }"></fa-layers-text>
73+ </fa-layers>`
74+ } )
75+ class HostComponent {
76+ faUser = faUser ;
77+ faMobile = faMobile ;
78+ }
79+
80+ const fixture = initTest ( HostComponent ) ;
81+ fixture . detectChanges ( ) ;
82+ expect ( queryByCss ( fixture , '.fa-fw' ) ) . toBeTruthy ( ) ;
83+ } ) ;
84+
85+
86+ it ( 'should not include fixed width' , ( ) => {
87+ @Component ( {
88+ selector : 'fa-host' ,
89+ template : `
90+ <fa-layers [fixedWidth]="false">
91+ <fa-icon [icon]="faUser"></fa-icon>
92+ <fa-icon [icon]="faMobile"></fa-icon>
93+ <fa-layers-text [content]="'User with mobile'" [styles]="{ color: 'Tomato' }"></fa-layers-text>
94+ </fa-layers>`
95+ } )
96+ class HostComponent {
97+ faUser = faUser ;
98+ faMobile = faMobile ;
99+ }
100+ const fixture = initTest ( HostComponent ) ;
101+ fixture . detectChanges ( ) ;
102+ expect ( queryByCss ( fixture , '.fa-fw' ) ) . toBeFalsy ( ) ;
103+ } ) ;
40104} ) ;
105+
0 commit comments