Skip to content

Commit

Permalink
fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienBtr committed Nov 7, 2020
1 parent 7a98f01 commit 1a666c3
Show file tree
Hide file tree
Showing 8 changed files with 5,735 additions and 13 deletions.
4 changes: 3 additions & 1 deletion services/user/src/controllers/createUser.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const winston = require('winston');
* Check if the body of the request contains the good elements
*/
const bodyIsValid = (body) => {
const { firstName, lastName, email, password } = body;
const {
firstName, lastName, email, password,
} = body;
if (!firstName || !lastName || !email || !password) {
return false;
}
Expand Down
4 changes: 3 additions & 1 deletion services/user/src/controllers/updateUserById.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const winston = require('winston');
* Check if the body of the request contains the good elements
*/
const bodyIsValid = (body) => {
const { firstName, lastName, email, password } = body;
const {
firstName, lastName, email, password,
} = body;
if (!firstName || !lastName || !email || !password) {
return false;
}
Expand Down
7 changes: 3 additions & 4 deletions services/user/src/tests/createUser.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef */
const request = require('supertest');
const app = require('../server');
const { prisma } = require('../../generated/prisma-client');
Expand Down Expand Up @@ -32,15 +32,14 @@ describe('Create a user', () => {
expect(res.body).toHaveProperty('createdAt');
expect(res.body).toHaveProperty('updatedAt');
done();
});
});
it.each(
[{"lastName":"lastName","email":"email","password":"password"},{"firstName":"firstName","email":"email","password":"password"},{"firstName":"firstName","lastName":"lastName","password":"password"},{"firstName":"firstName","lastName":"lastName","email":"email"}]
[{ lastName: 'lastName', email: 'email', password: 'password' }, { firstName: 'firstName', email: 'email', password: 'password' }, { firstName: 'firstName', lastName: 'lastName', password: 'password' }, { firstName: 'firstName', lastName: 'lastName', email: 'email' }],
)('Should return a 400 because a required field is missing', async (data, done) => {
const res = await request(app)
.put('/users')
.send(data);
expect(res.statusCode).toEqual(400);
done();
});

});
2 changes: 1 addition & 1 deletion services/user/src/tests/deleteUser.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef */
const request = require('supertest');
const app = require('../server');
const { prisma } = require('../../generated/prisma-client');
Expand Down
2 changes: 1 addition & 1 deletion services/user/src/tests/getUserById.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef */
const request = require('supertest');
const app = require('../server');
const { prisma } = require('../../generated/prisma-client');
Expand Down
2 changes: 1 addition & 1 deletion services/user/src/tests/getUsers.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef */
const request = require('supertest');
const app = require('../server');
const { prisma } = require('../../generated/prisma-client');
Expand Down
8 changes: 4 additions & 4 deletions services/user/src/tests/updateUserById.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-undef */
/* eslint-disable no-undef */
const request = require('supertest');
const app = require('../server');
const { prisma } = require('../../generated/prisma-client');
Expand Down Expand Up @@ -46,17 +46,17 @@ describe('Update a user by id', () => {
expect(res.body).toHaveProperty('updatedAt');
expect(res.body.updatedAt).toEqual(sampleOk.updatedAt);
done();
});
});
it.each(
[{"lastName":"lastName","email":"email","password":"password"},{"firstName":"firstName","email":"email","password":"password"},{"firstName":"firstName","lastName":"lastName","password":"password"},{"firstName":"firstName","lastName":"lastName","email":"email"}]
[{ lastName: 'lastName', email: 'email', password: 'password' }, { firstName: 'firstName', email: 'email', password: 'password' }, { firstName: 'firstName', lastName: 'lastName', password: 'password' }, { firstName: 'firstName', lastName: 'lastName', email: 'email' }],
)('Should return a 400 because a required field is missing', async (data, done) => {
const res = await request(app)
.put(`/users/${presentId}`)
.send(data);
expect(res.statusCode).toEqual(400);
done();
});

it('404 error case', async (done) => {
const res = await request(app)
.put(`/users/${notPresentId}`)
Expand Down
Loading

0 comments on commit 1a666c3

Please sign in to comment.