Skip to content

Commit

Permalink
test: [refactor] - remove the error test as it is not the functionali…
Browse files Browse the repository at this point in the history
…ty of it

#6
  • Loading branch information
Christiangsn committed Mar 8, 2023
1 parent 41b9b75 commit 8e8cafb
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions tests/@application/useCases/user/signup/signupUseCase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('SignUpUseCase', () => {
it('Shpuld fails if user already exists for provided email', async () => {
jest.spyOn(userRepository, 'exist').mockResolvedValueOnce(true)
const fakerDTO = fakeDTO()
const result = await sut.run(fakerDTO)
const result = await sut.execute(fakerDTO)

expect(userRepository.exist).toHaveBeenCalledWith({ email: fakerDTO.email })
expect(userRepository.exist).toHaveBeenCalledTimes(1)
Expand All @@ -68,18 +68,10 @@ describe('SignUpUseCase', () => {
jest.spyOn(userRepository, 'save').mockResolvedValueOnce()

const fakerDTO = fakeDTO()
const result = await sut.run(fakerDTO)
const result = await sut.execute(fakerDTO)

expect(userRepository.save).toHaveBeenCalledTimes(1)
expect(result.isFailure).toBe(false)
expect(result.isSuccess).toBe(true)
})

it('Should rethrow if methods IUserRepositoryContract throws', async () => {
userRepository.save.mockRejectedValueOnce(new Error('Failed in save user'))

const fakerDTO = fakeDTO()
const promise = sut.run(fakerDTO)
await expect(promise).rejects.toThrow(new Error('Failed in save user'))
})
})

0 comments on commit 8e8cafb

Please sign in to comment.