@@ -11,11 +11,11 @@ import { Component } from '@angular/core';
1111import { faUser } from ' @fortawesome/free-solid-svg-icons' ;
1212
1313@Component ({
14- selector: ' app-explicit-reference' ,
15- template: ' <fa-icon [icon]="faUser" />' ,
14+ selector: ' app-explicit-reference' ,
15+ template: ' <fa-icon [icon]="faUser" />' ,
1616})
1717export class ExplicitReferenceComponent {
18- faUser = faUser ;
18+ faUser = faUser ;
1919}
2020```
2121
@@ -25,26 +25,27 @@ import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
2525import { ExplicitReferenceComponent } from ' ./explicit-reference.component' ;
2626
2727describe (' ExplicitReferenceComponent' , () => {
28- let component: ExplicitReferenceComponent ;
29- let fixture: ComponentFixture <ExplicitReferenceComponent >;
30-
31- beforeEach (() => {
32- TestBed .configureTestingModule ({
33- imports: [FontAwesomeModule ], // <--
34- declarations: [ExplicitReferenceComponent ],
35- });
36- });
28+ let component: ExplicitReferenceComponent ;
29+ let fixture: ComponentFixture <ExplicitReferenceComponent >;
3730
38- beforeEach (() => {
39- fixture = TestBed .createComponent ( ExplicitReferenceComponent );
40- component = fixture . componentInstance ;
41- fixture . detectChanges ();
31+ beforeEach (() => {
32+ TestBed .configureTestingModule ({
33+ imports: [ FontAwesomeModule ], // <--
34+ declarations: [ ExplicitReferenceComponent ],
4235 });
36+ });
4337
44- it (' should create' , () => {
45- expect (component ).toBeTruthy ();
46- });
38+ beforeEach (() => {
39+ fixture = TestBed .createComponent (ExplicitReferenceComponent );
40+ component = fixture .componentInstance ;
41+ fixture .detectChanges ();
42+ });
43+
44+ it (' should create' , () => {
45+ expect (component ).toBeTruthy ();
46+ });
4747});
48+
4849```
4950
5051## Test components using [ icon library] ( ../usage/icon-library.md )
@@ -67,13 +68,13 @@ import { FaIconLibrary, FontAwesomeModule } from '@fortawesome/angular-fontaweso
6768import { faUser } from ' @fortawesome/free-solid-svg-icons' ;
6869
6970@NgModule ({
70- imports: [FontAwesomeModule ],
71- exports: [FontAwesomeModule ],
71+ imports: [FontAwesomeModule ],
72+ exports: [FontAwesomeModule ],
7273})
7374class FontAwesomeIconsModule {
74- constructor (library : FaIconLibrary ) {
75- library .addIcons (faUser );
76- }
75+ constructor (library : FaIconLibrary ) {
76+ library .addIcons (faUser );
77+ }
7778}
7879```
7980
@@ -83,8 +84,8 @@ And here is how it should be used in test code:
8384import { Component } from ' @angular/core' ;
8485
8586@Component ({
86- selector: ' app-regular-icon-library' ,
87- template: ' <fa-icon icon="user" />' ,
87+ selector: ' app-regular-icon-library' ,
88+ template: ' <fa-icon icon="user" />' ,
8889})
8990export class IconLibraryComponent {}
9091```
@@ -94,29 +95,29 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
9495import { IconLibraryComponent } from ' ./icon-library.component' ;
9596
9697describe (' IconLibraryComponent' , () => {
97- let component: IconLibraryComponent ;
98- let fixture: ComponentFixture <IconLibraryComponent >;
99-
100- beforeEach (() => {
101- TestBed .configureTestingModule ({
102- imports: [FontAwesomeIconsModule ], // <--
103- declarations: [IconLibraryComponent ],
104- });
105- });
98+ let component: IconLibraryComponent ;
99+ let fixture: ComponentFixture <IconLibraryComponent >;
106100
107- beforeEach (() => {
108- fixture = TestBed .createComponent ( IconLibraryComponent );
109- component = fixture . componentInstance ;
110- fixture . detectChanges ();
101+ beforeEach (() => {
102+ TestBed .configureTestingModule ({
103+ imports: [ FontAwesomeIconsModule ], // <--
104+ declarations: [ IconLibraryComponent ],
111105 });
106+ });
112107
113- it (' should create' , () => {
114- expect (component ).toBeTruthy ();
115- });
108+ beforeEach (() => {
109+ fixture = TestBed .createComponent (IconLibraryComponent );
110+ component = fixture .componentInstance ;
111+ fixture .detectChanges ();
112+ });
113+
114+ it (' should create' , () => {
115+ expect (component ).toBeTruthy ();
116+ });
116117});
117118```
118119
119- _ This approach was [ initially suggested by 1FpGLLjZSZMx6k on StackOverflow] ( https://stackoverflow.com/a/58380192/1377864 ) ._
120+ * This approach was [ initially suggested by 1FpGLLjZSZMx6k on StackOverflow] ( https://stackoverflow.com/a/58380192/1377864 ) .*
120121
121122### Configure regular ` FaIconLibrary `
122123
@@ -126,8 +127,8 @@ To use this approach you'll need to add `FontAwesomeModule` to the `imports` of
126127import { Component } from ' @angular/core' ;
127128
128129@Component ({
129- selector: ' app-regular-icon-library' ,
130- template: ' <fa-icon icon="user" />' ,
130+ selector: ' app-regular-icon-library' ,
131+ template: ' <fa-icon icon="user" />' ,
131132})
132133export class IconLibraryComponent {}
133134```
@@ -139,29 +140,29 @@ import { faUser } from '@fortawesome/free-solid-svg-icons';
139140import { IconLibraryComponent } from ' ./icon-library.component' ;
140141
141142describe (' IconLibraryComponent' , () => {
142- let component: IconLibraryComponent ;
143- let fixture: ComponentFixture <IconLibraryComponent >;
144-
145- beforeEach (() => {
146- TestBed .configureTestingModule ({
147- imports: [FontAwesomeModule ], // <--
148- declarations: [IconLibraryComponent ],
149- });
143+ let component: IconLibraryComponent ;
144+ let fixture: ComponentFixture <IconLibraryComponent >;
145+
146+ beforeEach (() => {
147+ TestBed .configureTestingModule ({
148+ imports: [FontAwesomeModule ], // <--
149+ declarations: [IconLibraryComponent ],
150150 });
151+ });
151152
152- beforeEach (() => {
153- // Use TestBed.get(FaIconLibrary) if you use Angular < 9.
154- const library = TestBed .inject (FaIconLibrary ); // <--
155- library .addIcons (faUser ); // <--
153+ beforeEach (() => {
154+ // Use TestBed.get(FaIconLibrary) if you use Angular < 9.
155+ const library = TestBed .inject (FaIconLibrary ); // <--
156+ library .addIcons (faUser ); // <--
156157
157- fixture = TestBed .createComponent (IconLibraryComponent );
158- component = fixture .componentInstance ;
159- fixture .detectChanges ();
160- });
158+ fixture = TestBed .createComponent (IconLibraryComponent );
159+ component = fixture .componentInstance ;
160+ fixture .detectChanges ();
161+ });
161162
162- it (' should create' , () => {
163- expect (component ).toBeTruthy ();
164- });
163+ it (' should create' , () => {
164+ expect (component ).toBeTruthy ();
165+ });
165166});
166167```
167168
@@ -173,8 +174,8 @@ describe('IconLibraryComponent', () => {
173174import { Component } from ' @angular/core' ;
174175
175176@Component ({
176- selector: ' app-regular-icon-library' ,
177- template: ' <fa-icon icon="user" />' ,
177+ selector: ' app-regular-icon-library' ,
178+ template: ' <fa-icon icon="user" />' ,
178179})
179180export class IconLibraryComponent {}
180181```
@@ -185,24 +186,24 @@ import { FontAwesomeTestingModule } from '@fortawesome/angular-fontawesome/testi
185186import { IconLibraryComponent } from ' ./icon-library.component' ;
186187
187188describe (' IconLibraryComponent' , () => {
188- let component: IconLibraryComponent ;
189- let fixture: ComponentFixture <IconLibraryComponent >;
190-
191- beforeEach (() => {
192- TestBed .configureTestingModule ({
193- imports: [FontAwesomeTestingModule ], // <--
194- declarations: [IconLibraryComponent ],
195- });
196- });
189+ let component: IconLibraryComponent ;
190+ let fixture: ComponentFixture <IconLibraryComponent >;
197191
198- beforeEach (() => {
199- fixture = TestBed .createComponent ( IconLibraryComponent );
200- component = fixture . componentInstance ;
201- fixture . detectChanges ();
192+ beforeEach (() => {
193+ TestBed .configureTestingModule ({
194+ imports: [ FontAwesomeTestingModule ], // <--
195+ declarations: [ IconLibraryComponent ],
202196 });
197+ });
203198
204- it (' should create' , () => {
205- expect (component ).toBeTruthy ();
206- });
199+ beforeEach (() => {
200+ fixture = TestBed .createComponent (IconLibraryComponent );
201+ component = fixture .componentInstance ;
202+ fixture .detectChanges ();
203+ });
204+
205+ it (' should create' , () => {
206+ expect (component ).toBeTruthy ();
207+ });
207208});
208209```
0 commit comments