From b645f28daf1ae23a9a2f86415b26d368504fdd6f Mon Sep 17 00:00:00 2001 From: Julien Gautier Date: Sun, 26 Apr 2026 05:28:58 +0200 Subject: [PATCH] fix(tests): fix all 39 failing specs and re-enable pre-commit hook - Fix circular dependency in guildwar-attack/defence: import FortificationCardContentComponent directly instead of via @components/shared barrel - Add index === -1 guard in guildwar-attack, guildwar-defence, guildwar-teams _setChampionsByPower to avoid crash when members input is empty - Fix MembersStatisticsComponent to guard against undefined member in ngOnInit - Fix JumpComponent: initialize jump with sautants/author defaults to avoid template crash - Add provideRouter([]), provideHttpClient(), provideAnimations(), provideNativeDateAdapter() to 26 spec files missing them - Register Chart.js scales in chart component specs - Rewrite FrenchPaginator spec to instantiate service directly - Fix AppComponent spec assertions to match actual component - Re-enable npm test in .husky/pre-commit --- .claude/settings.json | 12 +++++++++++ .husky/pre-commit | 2 +- src/app/app.component.spec.ts | 18 +++++++++++++---- .../aeronefs/aeronefs.component.spec.ts | 12 ++++++++++- .../components/auth/auth.component.spec.ts | 12 +++++++++-- .../calculator/calculator.component.spec.ts | 16 +++++++++++++-- .../canopies/canopies.component.spec.ts | 12 ++++++++++- .../dashboard/dashboard.component.spec.ts | 12 +++++++++-- .../components/demo/demo.component.spec.ts | 8 +++++++- .../dropzones/dropzones.component.spec.ts | 20 +++++++++++++++++-- .../herowars-guildraid.component.spec.ts | 6 +++++- .../herowars-guildwar.component.spec.ts | 8 +++++++- .../herowars/herowars.component.spec.ts | 8 +++++++- .../components/home/home.component.spec.ts | 6 +++++- .../components/jump/jump.component.spec.ts | 14 ++++++++++++- src/app/components/jump/jump.component.ts | 2 +- .../components/jumps/jumps.component.spec.ts | 14 +++++++++++-- .../logbook/logbook.component.spec.ts | 16 +++++++++++++-- .../components/page/page.component.spec.ts | 10 +++++++++- .../product/product.component.spec.ts | 10 +++++++++- .../products/products.component.spec.ts | 10 +++++++++- .../profile/profile.component.spec.ts | 10 ++++++++-- src/app/components/qcm/qcm.component.spec.ts | 10 +++++++++- .../credentials/credentials.component.spec.ts | 10 +++++++++- .../settings/settings.component.spec.ts | 10 +++++++++- .../aeronefs-bar.component.spec.ts | 16 ++++++++++++--- .../aeronefs-pie.component.spec.ts | 14 +++++++++++-- .../canopies-models.component.spec.ts | 14 +++++++++++-- .../canopies-sizes.component.spec.ts | 14 +++++++++++-- .../dropzones-bar.component.spec.ts | 14 +++++++++++-- .../dropzones-pie.component.spec.ts | 14 +++++++++++-- .../jumps-by-month.component.spec.ts | 14 ++++++++++--- .../shared/french-paginator.component.spec.ts | 18 ++++------------- .../guildraids-log.component.spec.ts | 8 +++++++- .../guildwar-attack.component.ts | 3 ++- .../guildwar-defence.component.ts | 14 +++++++------ .../guildwar-teams.component.ts | 1 + .../members-statistics.component.ts | 2 ++ .../shared/layout/full.component.spec.ts | 10 +++++++++- .../shared/layout/header.component.spec.ts | 8 +++++++- 40 files changed, 358 insertions(+), 74 deletions(-) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..dbb9d59 --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,12 @@ +{ + "permissions": { + "allow": [ + "Bash(grep \" FAILED$\")", + "Bash(grep -A2 \" FAILED$\")", + "Bash(grep -A3 \" FAILED$\")", + "Bash(grep -v \"Executed\\\\|^--$\")", + "Bash(grep -E \"TOTAL:|FAILED$\")", + "Bash(node -e \"const c = require\\('chart.js'\\); console.log\\(Object.keys\\(c\\).filter\\(k => k.includes\\('Doughnut'\\) || k.includes\\('Controller'\\)\\)\\)\")" + ] + } +} diff --git a/.husky/pre-commit b/.husky/pre-commit index ada238b..a9ba2da 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,3 +1,3 @@ -# npm test -- --watch=false +npm test -- --watch=false #prettier $(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') --write --ignore-unknown #git update-index --again \ No newline at end of file diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index a095620..d71a815 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,10 +1,20 @@ import { TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideNativeDateAdapter } from '@angular/material/core'; import { AppComponent } from './app.component'; describe('AppComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ imports: [AppComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + provideNativeDateAdapter(), + ], }).compileComponents(); }); @@ -14,16 +24,16 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have the 'adastra_angular' title`, () => { + it(`should have the 'Ad Astra' title`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; - expect(app.title).toEqual('adastra_angular'); + expect(app.title).toEqual('Ad Astra'); }); - it('should render title', () => { + it('should render the full layout', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('h1')?.textContent).toContain('Hello, adastra_angular'); + expect(compiled.querySelector('app-full-layout')).toBeTruthy(); }); }); diff --git a/src/app/components/aeronefs/aeronefs.component.spec.ts b/src/app/components/aeronefs/aeronefs.component.spec.ts index 219a518..e7ef044 100644 --- a/src/app/components/aeronefs/aeronefs.component.spec.ts +++ b/src/app/components/aeronefs/aeronefs.component.spec.ts @@ -1,5 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { MenuItems } from '@components/shared'; import { AeronefsComponent } from './aeronefs.component'; describe('AeronefsComponent', () => { @@ -8,7 +12,13 @@ describe('AeronefsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [AeronefsComponent] + imports: [AeronefsComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + MenuItems, + ], }) .compileComponents(); diff --git a/src/app/components/auth/auth.component.spec.ts b/src/app/components/auth/auth.component.spec.ts index da6d393..618ecb7 100644 --- a/src/app/components/auth/auth.component.spec.ts +++ b/src/app/components/auth/auth.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { AuthComponent } from './auth.component'; @@ -8,8 +11,13 @@ describe('AuthComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [AuthComponent] -}); + imports: [AuthComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], + }); fixture = TestBed.createComponent(AuthComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/calculator/calculator.component.spec.ts b/src/app/components/calculator/calculator.component.spec.ts index 2400cb7..465ef56 100644 --- a/src/app/components/calculator/calculator.component.spec.ts +++ b/src/app/components/calculator/calculator.component.spec.ts @@ -1,5 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement); +import { MenuItems } from '@components/shared'; import { CalculatorComponent } from './calculator.component'; describe('CalculatorComponent', () => { @@ -8,8 +14,14 @@ describe('CalculatorComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [CalculatorComponent] -}); + imports: [CalculatorComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }); fixture = TestBed.createComponent(CalculatorComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/canopies/canopies.component.spec.ts b/src/app/components/canopies/canopies.component.spec.ts index e415ea2..eb6bcea 100644 --- a/src/app/components/canopies/canopies.component.spec.ts +++ b/src/app/components/canopies/canopies.component.spec.ts @@ -1,5 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { MenuItems } from '@components/shared'; import { CanopiesComponent } from './canopies.component'; describe('CanopiesComponent', () => { @@ -8,7 +12,13 @@ describe('CanopiesComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [CanopiesComponent] + imports: [CanopiesComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + MenuItems, + ], }) .compileComponents(); diff --git a/src/app/components/dashboard/dashboard.component.spec.ts b/src/app/components/dashboard/dashboard.component.spec.ts index f5caa3d..152623e 100644 --- a/src/app/components/dashboard/dashboard.component.spec.ts +++ b/src/app/components/dashboard/dashboard.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { DashboardComponent } from './dashboard.component'; @@ -8,8 +11,13 @@ describe('DashboardComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [DashboardComponent] -}); + imports: [DashboardComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], + }); fixture = TestBed.createComponent(DashboardComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/demo/demo.component.spec.ts b/src/app/components/demo/demo.component.spec.ts index 895b441..94b8747 100644 --- a/src/app/components/demo/demo.component.spec.ts +++ b/src/app/components/demo/demo.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; import { DemoComponent } from './demo.component'; @@ -8,7 +10,11 @@ describe('DemoComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [DemoComponent] + imports: [DemoComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + ], }) .compileComponents(); diff --git a/src/app/components/dropzones/dropzones.component.spec.ts b/src/app/components/dropzones/dropzones.component.spec.ts index cf69b3a..a0278d9 100644 --- a/src/app/components/dropzones/dropzones.component.spec.ts +++ b/src/app/components/dropzones/dropzones.component.spec.ts @@ -1,5 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { GoogleMap, MapKmlLayer } from '@angular/google-maps'; +import { MenuItems } from '@components/shared'; import { DropzonesComponent } from './dropzones.component'; describe('DropzonesComponent', () => { @@ -8,10 +14,20 @@ describe('DropzonesComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [DropzonesComponent] + imports: [DropzonesComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) + .overrideComponent(DropzonesComponent, { + remove: { imports: [GoogleMap, MapKmlLayer] }, + add: { schemas: [CUSTOM_ELEMENTS_SCHEMA] }, }) .compileComponents(); - + fixture = TestBed.createComponent(DropzonesComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/herowars-guildraid/herowars-guildraid.component.spec.ts b/src/app/components/herowars-guildraid/herowars-guildraid.component.spec.ts index 9bdf140..d578924 100644 --- a/src/app/components/herowars-guildraid/herowars-guildraid.component.spec.ts +++ b/src/app/components/herowars-guildraid/herowars-guildraid.component.spec.ts @@ -1,4 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { HerowarsGuildraidComponent } from './herowars-guildraid.component'; @@ -8,7 +9,10 @@ describe('HerowarsGuildraidComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [HerowarsGuildraidComponent] + imports: [HerowarsGuildraidComponent], + providers: [ + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/herowars-guildwar/herowars-guildwar.component.spec.ts b/src/app/components/herowars-guildwar/herowars-guildwar.component.spec.ts index d1a3d24..ec023c5 100644 --- a/src/app/components/herowars-guildwar/herowars-guildwar.component.spec.ts +++ b/src/app/components/herowars-guildwar/herowars-guildwar.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { HerowarsGuildwarComponent } from './herowars-guildwar.component'; @@ -8,7 +10,11 @@ describe('HerowarsGuildwarComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [HerowarsGuildwarComponent] + imports: [HerowarsGuildwarComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/herowars/herowars.component.spec.ts b/src/app/components/herowars/herowars.component.spec.ts index 0636ce2..64910b7 100644 --- a/src/app/components/herowars/herowars.component.spec.ts +++ b/src/app/components/herowars/herowars.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideNativeDateAdapter } from '@angular/material/core'; import { HerowarsComponent } from './herowars.component'; @@ -8,7 +10,11 @@ describe('HerowarsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [HerowarsComponent] + imports: [HerowarsComponent], + providers: [ + provideAnimations(), + provideNativeDateAdapter(), + ], }) .compileComponents(); diff --git a/src/app/components/home/home.component.spec.ts b/src/app/components/home/home.component.spec.ts index 60c47c4..f17a537 100644 --- a/src/app/components/home/home.component.spec.ts +++ b/src/app/components/home/home.component.spec.ts @@ -1,4 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { HomeComponent } from './home.component'; @@ -8,7 +9,10 @@ describe('HomeComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [HomeComponent] + imports: [HomeComponent], + providers: [ + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/jump/jump.component.spec.ts b/src/app/components/jump/jump.component.spec.ts index 474dc8c..0696720 100644 --- a/src/app/components/jump/jump.component.spec.ts +++ b/src/app/components/jump/jump.component.spec.ts @@ -1,5 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideNativeDateAdapter } from '@angular/material/core'; +import { MenuItems } from '@components/shared'; import { JumpComponent } from './jump.component'; describe('JumpComponent', () => { @@ -8,7 +13,14 @@ describe('JumpComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [JumpComponent] + imports: [JumpComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + provideNativeDateAdapter(), + MenuItems, + ], }) .compileComponents(); diff --git a/src/app/components/jump/jump.component.ts b/src/app/components/jump/jump.component.ts index ea3f811..7e25177 100644 --- a/src/app/components/jump/jump.component.ts +++ b/src/app/components/jump/jump.component.ts @@ -29,7 +29,7 @@ export class JumpComponent implements OnInit, OnDestroy { public title: string = ''; public errors: Errors = { errors: {} }; public destroyRef = inject(DestroyRef); - public jump: Jump = {} as Jump; + public jump: Jump = { sautants: [], author: {} } as unknown as Jump; public prevSlug: string = ''; public nextSlug: string = ''; diff --git a/src/app/components/jumps/jumps.component.spec.ts b/src/app/components/jumps/jumps.component.spec.ts index 48c78e8..a7cdf0c 100644 --- a/src/app/components/jumps/jumps.component.spec.ts +++ b/src/app/components/jumps/jumps.component.spec.ts @@ -1,5 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { MenuItems } from '@components/shared'; import { JumpsComponent } from './jumps.component'; describe('JumpsComponent', () => { @@ -8,8 +12,14 @@ describe('JumpsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [JumpsComponent] -}); + imports: [JumpsComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }); fixture = TestBed.createComponent(JumpsComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/logbook/logbook.component.spec.ts b/src/app/components/logbook/logbook.component.spec.ts index a7ac751..d8f1456 100644 --- a/src/app/components/logbook/logbook.component.spec.ts +++ b/src/app/components/logbook/logbook.component.spec.ts @@ -1,5 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideNativeDateAdapter } from '@angular/material/core'; +import { MenuItems } from '@components/shared'; import { LogbookComponent } from './logbook.component'; describe('LogbookComponent', () => { @@ -8,8 +13,15 @@ describe('LogbookComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [LogbookComponent] -}); + imports: [LogbookComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + provideNativeDateAdapter(), + MenuItems, + ], + }); fixture = TestBed.createComponent(LogbookComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/page/page.component.spec.ts b/src/app/components/page/page.component.spec.ts index c389595..dcf9aee 100644 --- a/src/app/components/page/page.component.spec.ts +++ b/src/app/components/page/page.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { PageComponent } from './page.component'; @@ -8,7 +11,12 @@ describe('PageComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [PageComponent] + imports: [PageComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/product/product.component.spec.ts b/src/app/components/product/product.component.spec.ts index fe69534..d3f5149 100644 --- a/src/app/components/product/product.component.spec.ts +++ b/src/app/components/product/product.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { ProductComponent } from './product.component'; @@ -8,7 +11,12 @@ describe('ProductComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ProductComponent] + imports: [ProductComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/products/products.component.spec.ts b/src/app/components/products/products.component.spec.ts index ca186a4..d5d42d8 100644 --- a/src/app/components/products/products.component.spec.ts +++ b/src/app/components/products/products.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { ProductsComponent } from './products.component'; @@ -8,7 +11,12 @@ describe('ProductsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ProductsComponent] + imports: [ProductsComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/profile/profile.component.spec.ts b/src/app/components/profile/profile.component.spec.ts index 57df256..8ffb3fd 100644 --- a/src/app/components/profile/profile.component.spec.ts +++ b/src/app/components/profile/profile.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; import { ProfileComponent } from './profile.component'; @@ -8,8 +10,12 @@ describe('ProfileComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ProfileComponent] -}); + imports: [ProfileComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + ], + }); fixture = TestBed.createComponent(ProfileComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/src/app/components/qcm/qcm.component.spec.ts b/src/app/components/qcm/qcm.component.spec.ts index 5e4c639..6668e2c 100644 --- a/src/app/components/qcm/qcm.component.spec.ts +++ b/src/app/components/qcm/qcm.component.spec.ts @@ -1,5 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { MenuItems } from '@components/shared'; import { QcmComponent } from './qcm.component'; describe('QcmComponent', () => { @@ -8,7 +11,12 @@ describe('QcmComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [QcmComponent] + imports: [QcmComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + MenuItems, + ], }); fixture = TestBed.createComponent(QcmComponent); component = fixture.componentInstance; diff --git a/src/app/components/settings/credentials/credentials.component.spec.ts b/src/app/components/settings/credentials/credentials.component.spec.ts index fab6017..5358a41 100644 --- a/src/app/components/settings/credentials/credentials.component.spec.ts +++ b/src/app/components/settings/credentials/credentials.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { CredentialsComponent } from './credentials.component'; @@ -8,7 +11,12 @@ describe('CredentialsComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [CredentialsComponent] + imports: [CredentialsComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/settings/settings.component.spec.ts b/src/app/components/settings/settings.component.spec.ts index f905de3..b6581ee 100644 --- a/src/app/components/settings/settings.component.spec.ts +++ b/src/app/components/settings/settings.component.spec.ts @@ -1,4 +1,7 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { SettingsComponent } from './settings.component'; @@ -8,7 +11,12 @@ describe('SettingsComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [SettingsComponent] + imports: [SettingsComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }).compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/aeronefs-bar/aeronefs-bar.component.spec.ts b/src/app/components/shared/dashboard-components/aeronefs-bar/aeronefs-bar.component.spec.ts index 2dbed21..a149bc5 100755 --- a/src/app/components/shared/dashboard-components/aeronefs-bar/aeronefs-bar.component.spec.ts +++ b/src/app/components/shared/dashboard-components/aeronefs-bar/aeronefs-bar.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement); +import { MenuItems } from '@components/shared'; import { AeronefsBarComponent } from './aeronefs-bar.component'; describe('AeronefsBarComponent', () => { @@ -7,9 +12,14 @@ describe('AeronefsBarComponent', () => { let fixture: ComponentFixture; beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - imports: [AeronefsBarComponent] -}) + TestBed.configureTestingModule({ + imports: [AeronefsBarComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/aeronefs-pie/aeronefs-pie.component.spec.ts b/src/app/components/shared/dashboard-components/aeronefs-pie/aeronefs-pie.component.spec.ts index b0af50a..0937951 100755 --- a/src/app/components/shared/dashboard-components/aeronefs-pie/aeronefs-pie.component.spec.ts +++ b/src/app/components/shared/dashboard-components/aeronefs-pie/aeronefs-pie.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController); +import { MenuItems } from '@components/shared'; import { AeronefsPieComponent } from './aeronefs-pie.component'; describe('AeronefsPieComponent', () => { @@ -8,8 +13,13 @@ describe('AeronefsPieComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [AeronefsPieComponent] -}) + imports: [AeronefsPieComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/canopies-models/canopies-models.component.spec.ts b/src/app/components/shared/dashboard-components/canopies-models/canopies-models.component.spec.ts index c80607c..c9da293 100755 --- a/src/app/components/shared/dashboard-components/canopies-models/canopies-models.component.spec.ts +++ b/src/app/components/shared/dashboard-components/canopies-models/canopies-models.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController); +import { MenuItems } from '@components/shared'; import { CanopiesModelsComponent } from './canopies-models.component'; describe('CanopiesModelsComponent', () => { @@ -8,8 +13,13 @@ describe('CanopiesModelsComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [CanopiesModelsComponent] -}) + imports: [CanopiesModelsComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/canopies-sizes/canopies-sizes.component.spec.ts b/src/app/components/shared/dashboard-components/canopies-sizes/canopies-sizes.component.spec.ts index b107adb..449eef3 100755 --- a/src/app/components/shared/dashboard-components/canopies-sizes/canopies-sizes.component.spec.ts +++ b/src/app/components/shared/dashboard-components/canopies-sizes/canopies-sizes.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController); +import { MenuItems } from '@components/shared'; import { CanopiesSizesComponent } from './canopies-sizes.component'; describe('CanopiesSizesComponent', () => { @@ -8,8 +13,13 @@ describe('CanopiesSizesComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [CanopiesSizesComponent] -}) + imports: [CanopiesSizesComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/dropzones-bar/dropzones-bar.component.spec.ts b/src/app/components/shared/dashboard-components/dropzones-bar/dropzones-bar.component.spec.ts index f9287c3..364bf4f 100755 --- a/src/app/components/shared/dashboard-components/dropzones-bar/dropzones-bar.component.spec.ts +++ b/src/app/components/shared/dashboard-components/dropzones-bar/dropzones-bar.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement); +import { MenuItems } from '@components/shared'; import { DropzonesBarComponent } from './dropzones-bar.component'; describe('DropzonesBarComponent', () => { @@ -8,8 +13,13 @@ describe('DropzonesBarComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [DropzonesBarComponent] -}) + imports: [DropzonesBarComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/dropzones-pie/dropzones-pie.component.spec.ts b/src/app/components/shared/dashboard-components/dropzones-pie/dropzones-pie.component.spec.ts index 8fe8b45..f9f0ac4 100755 --- a/src/app/components/shared/dashboard-components/dropzones-pie/dropzones-pie.component.spec.ts +++ b/src/app/components/shared/dashboard-components/dropzones-pie/dropzones-pie.component.spec.ts @@ -1,5 +1,10 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { Chart, CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController } from 'chart.js'; +Chart.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement, LineElement, PointElement, DoughnutController, PieController); +import { MenuItems } from '@components/shared'; import { DropzonesPieComponent } from './dropzones-pie.component'; describe('DropzonesPieComponent', () => { @@ -8,8 +13,13 @@ describe('DropzonesPieComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - imports: [DropzonesPieComponent] -}) + imports: [DropzonesPieComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/dashboard-components/jumps-by-month/jumps-by-month.component.spec.ts b/src/app/components/shared/dashboard-components/jumps-by-month/jumps-by-month.component.spec.ts index a9a3dbb..f0f58f7 100755 --- a/src/app/components/shared/dashboard-components/jumps-by-month/jumps-by-month.component.spec.ts +++ b/src/app/components/shared/dashboard-components/jumps-by-month/jumps-by-month.component.spec.ts @@ -1,5 +1,8 @@ import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { MenuItems } from '@components/shared'; import { JumpsByMonthComponent } from './jumps-by-month.component'; describe('JumpsByMonthComponent', () => { @@ -7,9 +10,14 @@ describe('JumpsByMonthComponent', () => { let fixture: ComponentFixture; beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - imports: [JumpsByMonthComponent] -}) + TestBed.configureTestingModule({ + imports: [JumpsByMonthComponent], + providers: [ + provideHttpClient(), + provideAnimations(), + MenuItems, + ], + }) .compileComponents(); })); diff --git a/src/app/components/shared/french-paginator.component.spec.ts b/src/app/components/shared/french-paginator.component.spec.ts index d4fdfeb..f36ae3c 100644 --- a/src/app/components/shared/french-paginator.component.spec.ts +++ b/src/app/components/shared/french-paginator.component.spec.ts @@ -1,24 +1,14 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { FrenchPaginator } from './french-paginator.component'; describe('FrenchPaginator', () => { - let component: FrenchPaginator; - let fixture: ComponentFixture; + let paginator: FrenchPaginator; - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [FrenchPaginator] - }) - .compileComponents(); - - fixture = TestBed.createComponent(FrenchPaginator); - component = fixture.componentInstance; - fixture.detectChanges(); + beforeEach(() => { + paginator = new FrenchPaginator(); }); it('should create', () => { - expect(component).toBeTruthy(); + expect(paginator).toBeTruthy(); }); }); diff --git a/src/app/components/shared/herowars-components/guildraids-log/guildraids-log.component.spec.ts b/src/app/components/shared/herowars-components/guildraids-log/guildraids-log.component.spec.ts index 131e456..4e57a58 100644 --- a/src/app/components/shared/herowars-components/guildraids-log/guildraids-log.component.spec.ts +++ b/src/app/components/shared/herowars-components/guildraids-log/guildraids-log.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideAnimations } from '@angular/platform-browser/animations'; +import { provideNativeDateAdapter } from '@angular/material/core'; import { GuildraidsLogComponent } from './guildraids-log.component'; @@ -8,7 +10,11 @@ describe('GuildraidsLogComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [GuildraidsLogComponent] + imports: [GuildraidsLogComponent], + providers: [ + provideAnimations(), + provideNativeDateAdapter(), + ], }) .compileComponents(); diff --git a/src/app/components/shared/herowars-components/guildwar-attack/guildwar-attack.component.ts b/src/app/components/shared/herowars-components/guildwar-attack/guildwar-attack.component.ts index 0ae65d2..832cdd8 100644 --- a/src/app/components/shared/herowars-components/guildwar-attack/guildwar-attack.component.ts +++ b/src/app/components/shared/herowars-components/guildwar-attack/guildwar-attack.component.ts @@ -4,7 +4,7 @@ import { MatCardModule } from '@angular/material/card'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; -import { FortificationCardContentComponent } from '@components/shared'; +import { FortificationCardContentComponent } from '../fortification-card-content/fortification-card-content.component'; import { HWGuildWarEnemySlot, HWGuildWarEnemyTeam, HWGuildWarFortification, HWGuildWarHeroTeam, HWGuildWarTitanTeam, HWGuildWarSlots, HWMember @@ -194,6 +194,7 @@ export class GuildwarAttackComponent implements OnInit { private _setChampionsByPower(): void { for (const [teamId, teamValues] of Object.entries(guildWarData.teams)) { const index = this.guildMembers.findIndex(member => member.id === teamId); + if (index === -1) continue; let totalHeroPower = 0; let totalTitanPower = 0; const heroes: HWGuildWarHeroTeam[] = []; diff --git a/src/app/components/shared/herowars-components/guildwar-defence/guildwar-defence.component.ts b/src/app/components/shared/herowars-components/guildwar-defence/guildwar-defence.component.ts index 65a7021..e61a375 100644 --- a/src/app/components/shared/herowars-components/guildwar-defence/guildwar-defence.component.ts +++ b/src/app/components/shared/herowars-components/guildwar-defence/guildwar-defence.component.ts @@ -4,7 +4,7 @@ import { MatCardModule } from '@angular/material/card'; import { MatDividerModule } from '@angular/material/divider'; import { MatIconModule } from '@angular/material/icon'; -import { FortificationCardContentComponent } from '@components/shared'; +import { FortificationCardContentComponent } from '../fortification-card-content/fortification-card-content.component'; //import { HWMember } from '@models'; import { HWGuildWarFortification, HWGuildWarHeroTeam, HWGuildWarSlots, HWGuildWarTitanTeam, HWMember } from '@models'; @@ -41,6 +41,7 @@ export class GuildwarDefenceComponent implements OnInit { ngOnInit() { for (const [teamId, teamValues] of Object.entries(guildWarData.teams)) { const index = this.guildMembers.findIndex(member => member.id === teamId); + if (index === -1) continue; let totalHeroPower = 0; let totalTitanPower = 0; const heroes: HWGuildWarHeroTeam[] = []; @@ -82,15 +83,16 @@ export class GuildwarDefenceComponent implements OnInit { const slots: HWGuildWarSlots = guildWarSlots.slots; let count = 0; indexes.forEach((data) => { + const member = this._championsByPower[data]; + if (!member) return; switch (type) { case 'heroes': - //console.log(name, data, this._championsByPower[data]); - teams.push(this._championsByPower[data]); - count += this._championsByPower[data].heroes.power; + teams.push(member); + count += member.heroes.power; break; case 'titans': - teams.push(this._championsByPower[data]); - count += this._championsByPower[data].titans.power; + teams.push(member); + count += member.titans.power; break; default: break; diff --git a/src/app/components/shared/herowars-components/guildwar-teams/guildwar-teams.component.ts b/src/app/components/shared/herowars-components/guildwar-teams/guildwar-teams.component.ts index 564d0c8..382968c 100644 --- a/src/app/components/shared/herowars-components/guildwar-teams/guildwar-teams.component.ts +++ b/src/app/components/shared/herowars-components/guildwar-teams/guildwar-teams.component.ts @@ -48,6 +48,7 @@ export class GuildwarTeamsComponent implements OnInit { for (const [teamId, teamValues] of Object.entries(guildWarData.teams)) { const index = this._championsByPower.findIndex(member => member.id === teamId); + if (index === -1) continue; let totalHeroPower = 0; let totalTitanPower = 0; const heroes: HWGuildWarHeroTeam[] = []; diff --git a/src/app/components/shared/herowars-components/members-statistics/members-statistics.component.ts b/src/app/components/shared/herowars-components/members-statistics/members-statistics.component.ts index 2157951..650f1ad 100644 --- a/src/app/components/shared/herowars-components/members-statistics/members-statistics.component.ts +++ b/src/app/components/shared/herowars-components/members-statistics/members-statistics.component.ts @@ -94,6 +94,8 @@ export class MembersStatisticsComponent implements OnInit { const index = this._membersByName.findIndex(member => member.id === data[1].userId); if (index !== -1) { this._membersByName[index].stat = stat; + } else { + continue; } this._membersByName[index].score = (this._membersByName[index].stat.dungeonActivitySum + this._membersByName[index].stat.activitySum + this._membersByName[index].stat.prestigeSum); this._membersByName[index].warGifts = (((guildData.clan.giftsCount / 2) * ((this._membersByName[index].clanWarSum * 10) / 100)) / 20); diff --git a/src/app/components/shared/layout/full.component.spec.ts b/src/app/components/shared/layout/full.component.spec.ts index b32f274..c1eb71c 100644 --- a/src/app/components/shared/layout/full.component.spec.ts +++ b/src/app/components/shared/layout/full.component.spec.ts @@ -1,4 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; +import { provideAnimations } from '@angular/platform-browser/animations'; import { FullComponent } from './full.component'; @@ -8,7 +11,12 @@ describe('FullComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [FullComponent] + imports: [FullComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + provideAnimations(), + ], }) .compileComponents(); diff --git a/src/app/components/shared/layout/header.component.spec.ts b/src/app/components/shared/layout/header.component.spec.ts index 739c783..6f87657 100644 --- a/src/app/components/shared/layout/header.component.spec.ts +++ b/src/app/components/shared/layout/header.component.spec.ts @@ -1,4 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { provideHttpClient } from '@angular/common/http'; import { HeaderComponent } from './header.component'; @@ -8,7 +10,11 @@ describe('HeaderComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [HeaderComponent] + imports: [HeaderComponent], + providers: [ + provideRouter([]), + provideHttpClient(), + ], }) .compileComponents();