Skip to content

Commit

Permalink
Feat(Video, ClassVideo, Module): On video uploaded event to upload video
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur-Poffo committed Feb 1, 2024
1 parent 2c5044d commit 5aff79a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-misused-promises": "off"
"@typescript-eslint/no-misused-promises": "off",
"no-new": "off"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@ import { makeVideo } from '../../../../../test/factories/make-video'
import { InMemoryFilesRepository } from '../../../../../test/repositories/in-memory-files-repository'
import { InMemoryVideosRepository } from '../../../../../test/repositories/in-memory-videos-repository'
import { FakeUploader } from '../../../../../test/storage/fake-uploader'
import { UploadFileUseCase } from './../use-cases/upload-file'
import { OnVideoUploaded } from './on-video-uploaded'

let inMemoryFilesRepository: InMemoryFilesRepository
let inMemoryVideosRepository: InMemoryVideosRepository
let fakeUploader: FakeUploader
let uploadFileUseCase: UploadFileUseCase

describe('On video uploaded', () => {
beforeEach(() => {
inMemoryFilesRepository = new InMemoryFilesRepository()
inMemoryVideosRepository = new InMemoryVideosRepository()
fakeUploader = new FakeUploader()
uploadFileUseCase = new UploadFileUseCase(inMemoryFilesRepository, fakeUploader)

new OnVideoUploaded(uploadFileUseCase)
})

it('should be able to upload a video', async () => {
const video = makeVideo()
await inMemoryVideosRepository.create(video)

expect(inMemoryFilesRepository.items[0]).toBe({
name: video.videoName
expect(inMemoryFilesRepository.items[0]).toMatchObject({
fileName: video.videoName
})
expect(fakeUploader.files[0]).toBe({
name: video.videoName
expect(fakeUploader.files[0]).toMatchObject({
fileName: video.videoName
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export class OnVideoUploaded implements EventHandler {
}

private async uploadVideo({ video }: VideoUploadedEvent) {
console.log('olá')

await this.uploadFileUseCase.exec({
fileName: video.videoName,
fileType: video.videoType,
Expand Down

0 comments on commit 5aff79a

Please sign in to comment.