Skip to content

Commit

Permalink
test: ensure signup controller returns 403 if user role is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
felinto-dev committed Aug 1, 2020
1 parent 2b062d3 commit bbe6b91
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignUpController } from './signup-controller'
import { MissingParamError, ServerError, EmailInUseError } from '@/presentation/errors'
import { MissingParamError, ServerError, EmailInUseError, InvalidParamError } from '@/presentation/errors'
import { HttpRequest } from '@/presentation/protocols'
import { ok, serverError, badRequest, forbidden } from '@/presentation/helpers/http/http-helper'
import { AuthenticationSpy, ValidationSpy, AddAccountSpy } from '@/presentation/test'
Expand Down Expand Up @@ -66,6 +66,18 @@ describe('SignUp Controller', () => {
expect(httpResponse).toEqual(forbidden(new EmailInUseError()))
})

test('Should return 403 if user role is provided', async () => {
const { sut } = makeSut()
const httpResponse = await sut.handle({
...mockRequest(),
body: {
...mockRequest().body,
role: 'admin'
}
})
expect(httpResponse).toEqual(forbidden(new InvalidParamError('role')))
})

test('Should return 200 if valid data is provided', async () => {
const { sut, authenticationSpy } = makeSut()
const httpResponse = await sut.handle(mockRequest())
Expand Down

0 comments on commit bbe6b91

Please sign in to comment.