refactor: Structure api mock data with folders
This commit is contained in:
@@ -3,7 +3,7 @@ import request from 'supertest';
|
|||||||
import app from '../../../../app.js';
|
import app from '../../../../app.js';
|
||||||
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
||||||
import { createUser } from '../../../../../test/factories/user';
|
import { createUser } from '../../../../../test/factories/user';
|
||||||
import currentUserPayload from '../../../../../test/payloads/current-user.js';
|
import getCurrentUserMock from '../../../../../test/mocks/rest/api/v1/users/get-current-user';
|
||||||
|
|
||||||
describe('GET /api/v1/users/me', () => {
|
describe('GET /api/v1/users/me', () => {
|
||||||
let role, currentUser, token;
|
let role, currentUser, token;
|
||||||
@@ -20,7 +20,7 @@ describe('GET /api/v1/users/me', () => {
|
|||||||
.set('Authorization', token)
|
.set('Authorization', token)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
const expectedPayload = currentUserPayload(currentUser, role);
|
const expectedPayload = getCurrentUserMock(currentUser, role);
|
||||||
expect(response.body).toEqual(expectedPayload);
|
expect(response.body).toEqual(expectedPayload);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -4,7 +4,7 @@ import app from '../../../../app.js';
|
|||||||
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
|
||||||
import { createUser } from '../../../../../test/factories/user';
|
import { createUser } from '../../../../../test/factories/user';
|
||||||
import { createPermission } from '../../../../../test/factories/permission';
|
import { createPermission } from '../../../../../test/factories/permission';
|
||||||
import userPayload from '../../../../../test/payloads/user.js';
|
import getUserMock from '../../../../../test/mocks/rest/api/v1/users/get-user';
|
||||||
|
|
||||||
describe('GET /api/v1/users/:userId', () => {
|
describe('GET /api/v1/users/:userId', () => {
|
||||||
let currentUser, currentUserRole, anotherUser, anotherUserRole, token;
|
let currentUser, currentUserRole, anotherUser, anotherUserRole, token;
|
||||||
@@ -30,7 +30,7 @@ describe('GET /api/v1/users/:userId', () => {
|
|||||||
.set('Authorization', token)
|
.set('Authorization', token)
|
||||||
.expect(200);
|
.expect(200);
|
||||||
|
|
||||||
const expectedPayload = userPayload(anotherUser, anotherUserRole);
|
const expectedPayload = getUserMock(anotherUser, anotherUserRole);
|
||||||
expect(response.body).toEqual(expectedPayload);
|
expect(response.body).toEqual(expectedPayload);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
const currentUserPayload = (currentUser, role) => {
|
const getCurrentUserMock = (currentUser, role) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
createdAt: currentUser.createdAt.toISOString(),
|
createdAt: currentUser.createdAt.toISOString(),
|
||||||
@@ -29,4 +29,4 @@ const currentUserPayload = (currentUser, role) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default currentUserPayload;
|
export default getCurrentUserMock;
|
@@ -1,4 +1,4 @@
|
|||||||
const userPayload = (currentUser, role) => {
|
const getUserMock = (currentUser, role) => {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
createdAt: currentUser.createdAt.toISOString(),
|
createdAt: currentUser.createdAt.toISOString(),
|
||||||
@@ -28,4 +28,4 @@ const userPayload = (currentUser, role) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export default userPayload;
|
export default getUserMock;
|
Reference in New Issue
Block a user