-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/languages/app/controllers/v1/auth/signupPostController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Body, Controller, HttpCode, Post } from '@nestjs/common'; | ||
import { ApiBadRequestResponse, ApiInternalServerErrorResponse, ApiTags } from '@nestjs/swagger'; | ||
import SignupPostDto from '@src/languages/app/controllers/v1/auth/signupPostDto'; | ||
|
||
@ApiTags('Auth') | ||
@Controller() | ||
export default class SignupPostController { | ||
public constructor() {} | ||
|
||
@Post('auth/signup') | ||
@HttpCode(201) | ||
@ApiBadRequestResponse({ description: 'Bad Request.' }) | ||
@ApiInternalServerErrorResponse({ description: 'Internal Server Error.' }) | ||
async run(@Body() _payload: SignupPostDto): Promise<void> { | ||
throw new Error('Not implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
export default class SignupPostDto { | ||
@ApiProperty() | ||
@IsNotEmpty() | ||
@IsString() | ||
name: string; | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
@IsEmail() | ||
email: string; | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
@IsString() | ||
token: string; | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
@IsString() | ||
provider: string; | ||
|
||
@ApiProperty() | ||
@IsString() | ||
photo: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { beforeAll, describe, beforeEach, afterAll, it } from '@jest/globals'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import request = require('supertest'); | ||
import { MikroORM } from '@mikro-orm/core'; | ||
import { createApplication, truncateTables } from '@test/acceptance/createApplication'; | ||
|
||
describe('Given a SignupPostController to handle', () => { | ||
let app: INestApplication; | ||
let orm: MikroORM; | ||
|
||
const prepareApp = async () => { | ||
const setup = await createApplication(); | ||
app = setup.app; | ||
orm = setup.orm; | ||
}; | ||
|
||
const closeApp = async () => { | ||
await orm.close(true); | ||
await app.close(); | ||
}; | ||
|
||
beforeAll(async () => { | ||
await prepareApp(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await closeApp(); | ||
}); | ||
|
||
describe('As a user I want to signup in the app', () => { | ||
async function startScenario() { | ||
await truncateTables(orm); | ||
} | ||
|
||
beforeEach(startScenario); | ||
|
||
it('should create the user', async () => { | ||
await request(app.getHttpServer()) | ||
.post('/auth/signup') | ||
.set('Authorization', 'Bearer mock-token') | ||
.send({ | ||
email: '[email protected]', | ||
password: 'test123', | ||
name: 'test', | ||
token: '123', | ||
provider: 'google', | ||
photo: '', | ||
}) | ||
.expect(201); | ||
}); | ||
}); | ||
}); |