Skip to content
This repository has been archived by the owner on Feb 26, 2022. It is now read-only.

Commit

Permalink
Add user test
Browse files Browse the repository at this point in the history
  • Loading branch information
gdprepo committed Jan 20, 2022
1 parent 64286e6 commit 137535f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
49 changes: 25 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"faker": "^5.5.3",
"fastest-validator": "^1.12.0",
"image-to-base64": "^2.2.0",
"image-uploader": "^2.0.2",
"multer": "^1.4.4",
"passport-jwt": "^4.0.0",
"pg": "^8.7.1",
Expand All @@ -64,9 +63,10 @@
"devDependencies": {
"@nestjs/cli": "^8.0.0",
"@nestjs/schematics": "^8.0.0",
"@nestjs/testing": "^8.0.0",
"@nestjs/testing": "^8.2.5",
"@types/express": "^4.17.13",
"@types/jest": "27.0.2",
"@types/jest": "^27.0.2",
"@types/mocha": "^9.1.0",
"@types/multer": "^1.4.7",
"@types/node": "^16.0.0",
"@types/passport-jwt": "^3.0.6",
Expand Down
25 changes: 25 additions & 0 deletions src/user/user.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { City } from '@prisma/client';
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

let cityCreate = {} as City;
beforeAll(async () => {
//create city
cityCreate = await prisma.city.create({
data: { name: 'Bordeaux', postalCode: '33000' },
});
});

it('sould return Bordeaux', async () => {
const newCity = await prisma.city.findUnique({
where: { id: cityCreate.id },
});
await expect(newCity).toStrictEqual(cityCreate);
});

it('Not return object Bordeaux', async () => {
const newCity = await prisma.city.findFirst();

await expect(newCity).not.toStrictEqual(cityCreate);
})
2 changes: 1 addition & 1 deletion src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { FileInterceptor } from '@nestjs/platform-express';
import { User } from '@prisma/client';
import { Response } from 'express';
import { CreateUserDto, FilterDto } from 'src/dtos';
import { CreateUserDto, FilterDto } from './../dtos';

import { UserService } from './user.service';

Expand Down
1 change: 1 addition & 0 deletions src/user/user.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import { UserService } from './user.service';
@Module({
controllers: [UserController],
providers: [UserService, PrismaService],
imports: [PrismaService],
})
export class UserModule {}

0 comments on commit 137535f

Please sign in to comment.