Skip to content

Commit

Permalink
corrigindo testes
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickMVdO committed Dec 12, 2024
1 parent 9b8c00d commit c4cae9d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
15 changes: 14 additions & 1 deletion src/app/pages/video/video.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { of, throwError } from 'rxjs';
import { VideoComponent } from './video.component';
import { VideoService } from '../../services/video.service';
import { IVideo } from 'src/shared/model/video.model';
import { MessageService } from 'primeng/api';

const mockData: IVideo[] = [
{
Expand Down Expand Up @@ -34,6 +35,8 @@ const mockData: IVideo[] = [
name: 'UnBTV',
},
],
isFavorited: false,
isWatchLater: false,
},
{
id: 190984,
Expand Down Expand Up @@ -61,6 +64,8 @@ const mockData: IVideo[] = [
name: 'UnBTV',
},
],
isFavorited: false,
isWatchLater: false,
},
{
id: 190334,
Expand Down Expand Up @@ -88,6 +93,8 @@ const mockData: IVideo[] = [
name: 'UnBTV',
},
],
isFavorited: false,
isWatchLater: false,
},
{
id: 190333,
Expand Down Expand Up @@ -115,6 +122,8 @@ const mockData: IVideo[] = [
name: 'UnBTV',
},
],
isFavorited: false,
isWatchLater: false,
},
{
id: 190324,
Expand Down Expand Up @@ -142,6 +151,8 @@ const mockData: IVideo[] = [
name: 'UnBTV',
},
],
isFavorited: false,
isWatchLater: false,
},
];

Expand All @@ -161,7 +172,9 @@ describe('VideoComponent', () => {
await TestBed.configureTestingModule({
declarations: [VideoComponent],
imports: [HttpClientTestingModule],
providers: [{ provide: VideoService, useValue: new VideoServiceMock() }],
providers: [{ provide: VideoService, useValue: new VideoServiceMock() },
MessageService,
],
}).compileComponents();

fixture = TestBed.createComponent(VideoComponent);
Expand Down
14 changes: 0 additions & 14 deletions src/app/pages/video/video.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class VideoComponent implements OnInit {
this.getUserDetails();
}
// Carrega o vídeo específico e ajusta o iframe
this.findVideoById();
if (iframe && this.idVideo) {
iframe.src = `${this.eduplayVideoUrl}${this.idVideo}`;
}
Expand Down Expand Up @@ -77,19 +76,6 @@ export class VideoComponent implements OnInit {
});
}

findVideoById(): void {
// Aqui você deve definir como pegar o idVideo, talvez com route ou outro método
// Como você já tem o idVideo, só faz a requisição
this.videoService.findVideoById(this.idVideo).subscribe({
next: (data) => {
// Aqui você pode armazenar o vídeo retornado, como já está no código original
},
error: (err) => {
console.error('Error fetching video details', err);
},
});
}

// Favoritar
toggleFavorite(video: IVideo): void {
const videoId = video.id ?? 0; // Se video.id for undefined, usa 0 como valor
Expand Down

0 comments on commit c4cae9d

Please sign in to comment.