Skip to content

Commit

Permalink
Corrige imports de testes
Browse files Browse the repository at this point in the history
  • Loading branch information
joao15victor08 committed Nov 11, 2023
1 parent edcbc25 commit 1517098
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -48,7 +47,6 @@ import { VideoCommentComponent } from './pages/video-viewer/video-comment/video-
AppRoutingModule,
HttpClientModule,
ReactiveFormsModule,
HttpClientModule,
],
providers: [
AuthGuard,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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;
let fixture: ComponentFixture<VideoCommentComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ VideoCommentComponent ]
declarations: [ VideoCommentComponent ],
imports: [HttpClientTestingModule, ReactiveFormsModule, RouterTestingModule],
providers: [FormBuilder, {provide: VideoService}]
})
.compileComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
4 changes: 3 additions & 1 deletion src/app/pages/register/register.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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', () => {
Expand Down
6 changes: 4 additions & 2 deletions src/app/pages/video-viewer/video-viewer.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ 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;
let fixture: ComponentFixture<VideoViewerComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [VideoViewerComponent, SafePipe],
declarations: [VideoViewerComponent, SafePipe, VideoCommentComponent],
imports: [HttpClientTestingModule, RouterTestingModule],
providers: [{ provide: VideoService }]
providers: [{ provide: VideoService }, FormBuilder]

})
.compileComponents();
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/user-token-interceptor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class UserTokenInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, 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: {
Expand Down
5 changes: 4 additions & 1 deletion src/app/services/video-comment.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});

Expand Down

0 comments on commit 1517098

Please sign in to comment.