diff --git a/angular.json b/angular.json index 1106809..6fa4108 100644 --- a/angular.json +++ b/angular.json @@ -96,6 +96,11 @@ { "glob": "**/*", "input": "public" + }, + { + "glob": "**/*", + "input": "src/assets", + "output": "/assets" } ], "styles": [ diff --git a/src/app/pages/about/about.component.spec.ts b/src/app/pages/about/about.component.spec.ts index e6b9833..5749d3d 100644 --- a/src/app/pages/about/about.component.spec.ts +++ b/src/app/pages/about/about.component.spec.ts @@ -1,7 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { Component, provideZonelessChangeDetection } from '@angular/core'; import { MatCardModule } from '@angular/material/card'; -import { By } from '@angular/platform-browser'; +import { By, DomSanitizer } from '@angular/platform-browser'; +import { MatIconRegistry } from '@angular/material/icon'; import { provideRouter } from '@angular/router'; import { provideTranslateService } from '@ngx-translate/core'; import { AboutComponent } from './about.component'; @@ -26,10 +27,26 @@ describe('AboutComponent', () => { ], }).compileComponents(); + registerStubIcons(); + fixture = TestBed.createComponent(AboutComponent); fixture.detectChanges(); }); + /** + * The real SVG icons are registered by an app initializer that TestBed never + * runs, so mat-icon logs a lookup error for every fixture. Literals keep the + * registry satisfied without pulling HttpClient into these tests. + */ + function registerStubIcons(): void { + const iconRegistry = TestBed.inject(MatIconRegistry); + const sanitizer = TestBed.inject(DomSanitizer); + const emptyIcon = sanitizer.bypassSecurityTrustHtml(''); + + iconRegistry.addSvgIconLiteral('linkedin', emptyIcon); + iconRegistry.addSvgIconLiteral('github', emptyIcon); + } + function textOf(selector: string): string[] { return fixture.debugElement .queryAll(By.css(selector)) @@ -163,7 +180,7 @@ describe('AboutComponent', () => { const mailButton = fixture.debugElement.query(By.css('[data-testid="contact-mail"]')).nativeElement; const siblingLink = fixture.debugElement .queryAll(By.css('a')) - .find(anchor => anchor.nativeElement.textContent.trim() === 'Codeberg')!.nativeElement; + .find(anchor => anchor.nativeElement.textContent.trim() === 'Gitea')!.nativeElement; const buttonStyle = getComputedStyle(mailButton); const linkStyle = getComputedStyle(siblingLink);