diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3989907f..7eb98f05 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -22,14 +22,13 @@ import { CheckCodeRestPasswordComponent } from './pages/check-code-rest-password import { AuthGuard } from './services/auth.guard'; import { AuthService } from './services/auth.service'; import { EditUserComponent } from './pages/edit-user/edit-user.component'; -import { VideoCommentComponent } from './pages/video-viewer/video-comment/video-comment.component'; +import { VideoCommentComponent } from './components/video-comment/video-comment.component'; @NgModule({ declarations: [ AppComponent, LoginComponent, RegisterComponent, - BackgroundComponent, LoginSocialComponent, VideoComponent, VideoViewerComponent, @@ -48,7 +47,6 @@ import { VideoCommentComponent } from './pages/video-viewer/video-comment/video- AppRoutingModule, HttpClientModule, ReactiveFormsModule, - HttpClientModule, ], providers: [ AuthGuard, diff --git a/src/app/pages/video-viewer/video-comment/video-comment.component.css b/src/app/components/video-comment/video-comment.component.css similarity index 100% rename from src/app/pages/video-viewer/video-comment/video-comment.component.css rename to src/app/components/video-comment/video-comment.component.css diff --git a/src/app/pages/video-viewer/video-comment/video-comment.component.html b/src/app/components/video-comment/video-comment.component.html similarity index 100% rename from src/app/pages/video-viewer/video-comment/video-comment.component.html rename to src/app/components/video-comment/video-comment.component.html diff --git a/src/app/pages/video-viewer/video-comment/video-comment.component.spec.ts b/src/app/components/video-comment/video-comment.component.spec.ts similarity index 56% rename from src/app/pages/video-viewer/video-comment/video-comment.component.spec.ts rename to src/app/components/video-comment/video-comment.component.spec.ts index 57681179..60a50e4a 100644 --- a/src/app/pages/video-viewer/video-comment/video-comment.component.spec.ts +++ b/src/app/components/video-comment/video-comment.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; - import { VideoCommentComponent } from './video-comment.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; +import { RouterTestingModule } from '@angular/router/testing'; +import { VideoService } from 'src/app/services/video.service'; describe('VideoCommentComponent', () => { let component: VideoCommentComponent; @@ -8,7 +11,9 @@ describe('VideoCommentComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ VideoCommentComponent ] + declarations: [ VideoCommentComponent ], + imports: [HttpClientTestingModule, ReactiveFormsModule, RouterTestingModule], + providers: [FormBuilder, {provide: VideoService}] }) .compileComponents(); diff --git a/src/app/pages/video-viewer/video-comment/video-comment.component.ts b/src/app/components/video-comment/video-comment.component.ts similarity index 92% rename from src/app/pages/video-viewer/video-comment/video-comment.component.ts rename to src/app/components/video-comment/video-comment.component.ts index e91d7238..5048baf7 100644 --- a/src/app/pages/video-viewer/video-comment/video-comment.component.ts +++ b/src/app/components/video-comment/video-comment.component.ts @@ -1,10 +1,10 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { VideoCommentService } from '../../../services/video-comment.service'; +import { VideoCommentService } from '../../services/video-comment.service'; import { ActivatedRoute } from '@angular/router'; import jwt_decode from 'jwt-decode'; -import { AuthService } from '../../../services/auth.service'; -import { Comment } from '../../../../shared/model/comment.model'; +import { AuthService } from '../../services/auth.service'; +import { Comment } from '../../../shared/model/comment.model'; import { UserService } from 'src/app/services/user.service'; @Component({ diff --git a/src/app/pages/register/register.component.spec.ts b/src/app/pages/register/register.component.spec.ts index af78b8bd..c8119786 100644 --- a/src/app/pages/register/register.component.spec.ts +++ b/src/app/pages/register/register.component.spec.ts @@ -57,8 +57,9 @@ describe('RegisterComponent', () => { }); it('should call register method when the form is submitted', () => { - fixture.detectChanges(); spyOn(component, 'register').and.callThrough(); + const alertSpy = spyOn(window, 'alert'); + fixture.detectChanges(); const form = component.userForm; form.setValue(mockData); @@ -68,6 +69,7 @@ describe('RegisterComponent', () => { submitButton.click(); expect(component.register).toHaveBeenCalled(); + expect(alertSpy).toHaveBeenCalledWith('Usuário cadastrado com sucesso!'); }); it('should call alert when form is not valid', () => { diff --git a/src/app/pages/video-viewer/video-viewer.component.spec.ts b/src/app/pages/video-viewer/video-viewer.component.spec.ts index 0fcedda5..86d4602e 100644 --- a/src/app/pages/video-viewer/video-viewer.component.spec.ts +++ b/src/app/pages/video-viewer/video-viewer.component.spec.ts @@ -4,6 +4,8 @@ import { RouterTestingModule } from "@angular/router/testing"; import { VideoViewerComponent } from './video-viewer.component'; import { VideoService } from '../../services/video.service'; import { SafePipe } from 'src/app/pipes/safe.pipe'; +import { VideoCommentComponent } from 'src/app/components/video-comment/video-comment.component'; +import { FormBuilder } from '@angular/forms'; describe('VideoViewerComponent', () => { let component: VideoViewerComponent; @@ -11,9 +13,9 @@ describe('VideoViewerComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [VideoViewerComponent, SafePipe], + declarations: [VideoViewerComponent, SafePipe, VideoCommentComponent], imports: [HttpClientTestingModule, RouterTestingModule], - providers: [{ provide: VideoService }] + providers: [{ provide: VideoService }, FormBuilder] }) .compileComponents(); diff --git a/src/app/services/user-token-interceptor.service.ts b/src/app/services/user-token-interceptor.service.ts index 895c40d4..1f27ab99 100644 --- a/src/app/services/user-token-interceptor.service.ts +++ b/src/app/services/user-token-interceptor.service.ts @@ -13,7 +13,7 @@ export class UserTokenInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler) { const token = localStorage.getItem('token'); console.log(request.url); - if (request.url.includes("localhost")) { + if (!request.url.includes("eduplay")) { if (token) { request = request.clone({ setHeaders: { diff --git a/src/app/services/video-comment.service.spec.ts b/src/app/services/video-comment.service.spec.ts index 1de05327..f58f72dc 100644 --- a/src/app/services/video-comment.service.spec.ts +++ b/src/app/services/video-comment.service.spec.ts @@ -1,12 +1,15 @@ import { TestBed } from '@angular/core/testing'; import { VideoCommentService } from './video-comment.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('VideoCommentService', () => { let service: VideoCommentService; beforeEach(() => { - TestBed.configureTestingModule({}); + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + }); service = TestBed.inject(VideoCommentService); });