From b6108c591a1fc2409031d086140827f20682df4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor?= Date: Mon, 6 Nov 2023 19:09:53 -0300 Subject: [PATCH] Corrige arquivos de testes geral --- karma.conf.js | 1 + src/app/app.component.spec.ts | 16 +++++++++++----- .../active-account.component.spec.ts | 10 +++++++--- .../check-code-rest-password.component.spec.ts | 10 +++++++--- .../pages/edit-user/edit-user.component.spec.ts | 9 ++++++--- src/app/pages/login/login.component.spec.ts | 6 ++++-- src/app/pages/profile/profile.component.spec.ts | 7 ++++--- .../pages/register/register.component.spec.ts | 10 +++++++--- src/app/services/auth.guard.spec.ts | 4 ++-- src/app/services/auth.service.spec.ts | 4 ++-- src/app/services/user.service.spec.ts | 4 ++-- 11 files changed, 53 insertions(+), 28 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 3687fb8e..10dfe918 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -42,6 +42,7 @@ module.exports = function (config) { { type: 'html' }, { type: 'lcov' }, { type: 'cobertura' }, + { type: 'text-summary' } ] }, reporters: ['progress', 'kjhtml'], diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index b183db08..3e256296 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,18 +1,24 @@ -import { TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; +import { BackgroundComponent } from './components/background/background.component'; describe('AppComponent', () => { + let component: AppComponent; + let fixture: ComponentFixture; + beforeEach(async () => { await TestBed.configureTestingModule({ imports: [RouterTestingModule], - declarations: [AppComponent], + declarations: [AppComponent, BackgroundComponent], }).compileComponents(); + + fixture = TestBed.createComponent(AppComponent); + component = fixture.componentInstance; + fixture.detectChanges(); }); it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); + expect(component).toBeTruthy(); }); }); diff --git a/src/app/pages/active-account/active-account.component.spec.ts b/src/app/pages/active-account/active-account.component.spec.ts index b8d287f9..2d16512e 100644 --- a/src/app/pages/active-account/active-account.component.spec.ts +++ b/src/app/pages/active-account/active-account.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { ActiveAccountComponent } from './active-account.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AuthService } from 'src/app/services/auth.service'; +import { ReactiveFormsModule } from '@angular/forms'; describe('ActiveAccountComponent', () => { let component: ActiveAccountComponent; @@ -8,9 +10,11 @@ describe('ActiveAccountComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ActiveAccountComponent ] + imports: [HttpClientTestingModule, ReactiveFormsModule], + providers: [AuthService], + declarations: [ActiveAccountComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(ActiveAccountComponent); component = fixture.componentInstance; diff --git a/src/app/pages/check-code-rest-password/check-code-rest-password.component.spec.ts b/src/app/pages/check-code-rest-password/check-code-rest-password.component.spec.ts index d6a7bf96..86a55a1c 100644 --- a/src/app/pages/check-code-rest-password/check-code-rest-password.component.spec.ts +++ b/src/app/pages/check-code-rest-password/check-code-rest-password.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { CheckCodeRestPasswordComponent } from './check-code-rest-password.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AuthService } from 'src/app/services/auth.service'; +import { ReactiveFormsModule } from '@angular/forms'; describe('CheckCodeRestPasswordComponent', () => { let component: CheckCodeRestPasswordComponent; @@ -8,9 +10,11 @@ describe('CheckCodeRestPasswordComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ CheckCodeRestPasswordComponent ] + imports: [HttpClientTestingModule, ReactiveFormsModule], + providers: [AuthService], + declarations: [CheckCodeRestPasswordComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(CheckCodeRestPasswordComponent); component = fixture.componentInstance; diff --git a/src/app/pages/edit-user/edit-user.component.spec.ts b/src/app/pages/edit-user/edit-user.component.spec.ts index 054644a2..c1728898 100644 --- a/src/app/pages/edit-user/edit-user.component.spec.ts +++ b/src/app/pages/edit-user/edit-user.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { EditUserComponent } from './edit-user.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ReactiveFormsModule } from '@angular/forms'; describe('EditUserComponent', () => { let component: EditUserComponent; @@ -8,9 +10,10 @@ describe('EditUserComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ EditUserComponent ] + imports: [HttpClientTestingModule, RouterTestingModule, ReactiveFormsModule], + declarations: [EditUserComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(EditUserComponent); component = fixture.componentInstance; diff --git a/src/app/pages/login/login.component.spec.ts b/src/app/pages/login/login.component.spec.ts index 67f55c61..e03216cb 100644 --- a/src/app/pages/login/login.component.spec.ts +++ b/src/app/pages/login/login.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LoginComponent } from './login.component'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AuthService } from 'src/app/services/auth.service'; describe('LoginComponent', () => { let component: LoginComponent; @@ -8,9 +10,9 @@ describe('LoginComponent', () => { beforeEach(async () => { TestBed.configureTestingModule({ + imports: [HttpClientTestingModule, ReactiveFormsModule], + providers: [FormBuilder, AuthService], declarations: [LoginComponent], - imports: [ReactiveFormsModule], - providers: [FormBuilder], }).compileComponents(); fixture = TestBed.createComponent(LoginComponent); diff --git a/src/app/pages/profile/profile.component.spec.ts b/src/app/pages/profile/profile.component.spec.ts index 246039d7..18ff5af5 100644 --- a/src/app/pages/profile/profile.component.spec.ts +++ b/src/app/pages/profile/profile.component.spec.ts @@ -1,6 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { ProfileComponent } from './profile.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ProfileComponent', () => { let component: ProfileComponent; @@ -8,9 +8,10 @@ describe('ProfileComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ProfileComponent ] + imports: [HttpClientTestingModule], + declarations: [ProfileComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(ProfileComponent); component = fixture.componentInstance; diff --git a/src/app/pages/register/register.component.spec.ts b/src/app/pages/register/register.component.spec.ts index f9755337..21c94378 100644 --- a/src/app/pages/register/register.component.spec.ts +++ b/src/app/pages/register/register.component.spec.ts @@ -1,6 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { RegisterComponent } from './register.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AuthService } from 'src/app/services/auth.service'; +import { ReactiveFormsModule } from '@angular/forms'; describe('RegisterComponent', () => { let component: RegisterComponent; @@ -8,9 +10,11 @@ describe('RegisterComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ RegisterComponent ] + imports: [HttpClientTestingModule, ReactiveFormsModule], + providers: [AuthService], + declarations: [RegisterComponent] }) - .compileComponents(); + .compileComponents(); fixture = TestBed.createComponent(RegisterComponent); component = fixture.componentInstance; diff --git a/src/app/services/auth.guard.spec.ts b/src/app/services/auth.guard.spec.ts index 68889d22..81d1c094 100644 --- a/src/app/services/auth.guard.spec.ts +++ b/src/app/services/auth.guard.spec.ts @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing'; - +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { AuthGuard } from './auth.guard'; describe('AuthGuard', () => { let guard: AuthGuard; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ imports: [HttpClientTestingModule], providers: [AuthGuard] }); guard = TestBed.inject(AuthGuard); }); diff --git a/src/app/services/auth.service.spec.ts b/src/app/services/auth.service.spec.ts index f1251cac..3acf0447 100644 --- a/src/app/services/auth.service.spec.ts +++ b/src/app/services/auth.service.spec.ts @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing'; - +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { AuthService } from './auth.service'; describe('AuthService', () => { let service: AuthService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ imports: [HttpClientTestingModule], providers: [AuthService] }); service = TestBed.inject(AuthService); }); diff --git a/src/app/services/user.service.spec.ts b/src/app/services/user.service.spec.ts index 3f804c9f..bd802828 100644 --- a/src/app/services/user.service.spec.ts +++ b/src/app/services/user.service.spec.ts @@ -1,12 +1,12 @@ import { TestBed } from '@angular/core/testing'; - import { UserService } from './user.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('UserService', () => { let service: UserService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ imports: [HttpClientTestingModule], providers: [UserService] }); service = TestBed.inject(UserService); });