-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathIsFileDeleted.test.ts
More file actions
33 lines (25 loc) · 1.27 KB
/
Copy pathIsFileDeleted.test.ts
File metadata and controls
33 lines (25 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { IFilesRepository } from '../../../src/files/domain/repositories/IFilesRepository'
import { IsFileDeleted } from '../../../src/files/domain/useCases/IsFileDeleted'
import { ReadError } from '../../../src'
describe('execute', () => {
test('should return true when file has been deleted', async () => {
const filesRepositoryStub: IFilesRepository = {} as IFilesRepository
filesRepositoryStub.isFileDeleted = jest.fn().mockResolvedValue(true)
const sut = new IsFileDeleted(filesRepositoryStub)
const result = await sut.execute(1)
expect(result).toBe(true)
})
test('should return false when file has not been deleted', async () => {
const filesRepositoryStub: IFilesRepository = {} as IFilesRepository
filesRepositoryStub.isFileDeleted = jest.fn().mockResolvedValue(false)
const sut = new IsFileDeleted(filesRepositoryStub)
const result = await sut.execute(1)
expect(result).toBe(false)
})
test('should return error result on repository error', async () => {
const filesRepositoryStub: IFilesRepository = {} as IFilesRepository
filesRepositoryStub.isFileDeleted = jest.fn().mockRejectedValue(new ReadError())
const sut = new IsFileDeleted(filesRepositoryStub)
await expect(sut.execute(1)).rejects.toThrow(ReadError)
})
})