refactor: Structure api mock data with folders

This commit is contained in:
Faruk AYDIN
2024-02-14 00:58:12 +01:00
parent da732becb6
commit d583e42428
4 changed files with 8 additions and 8 deletions

View File

@@ -3,7 +3,7 @@ import request from 'supertest';
import app from '../../../../app.js';
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
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', () => {
let role, currentUser, token;
@@ -20,7 +20,7 @@ describe('GET /api/v1/users/me', () => {
.set('Authorization', token)
.expect(200);
const expectedPayload = currentUserPayload(currentUser, role);
const expectedPayload = getCurrentUserMock(currentUser, role);
expect(response.body).toEqual(expectedPayload);
});
});

View File

@@ -4,7 +4,7 @@ import app from '../../../../app.js';
import createAuthTokenByUserId from '../../../../helpers/create-auth-token-by-user-id';
import { createUser } from '../../../../../test/factories/user';
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', () => {
let currentUser, currentUserRole, anotherUser, anotherUserRole, token;
@@ -30,7 +30,7 @@ describe('GET /api/v1/users/:userId', () => {
.set('Authorization', token)
.expect(200);
const expectedPayload = userPayload(anotherUser, anotherUserRole);
const expectedPayload = getUserMock(anotherUser, anotherUserRole);
expect(response.body).toEqual(expectedPayload);
});
});

View File

@@ -1,4 +1,4 @@
const currentUserPayload = (currentUser, role) => {
const getCurrentUserMock = (currentUser, role) => {
return {
data: {
createdAt: currentUser.createdAt.toISOString(),
@@ -29,4 +29,4 @@ const currentUserPayload = (currentUser, role) => {
};
};
export default currentUserPayload;
export default getCurrentUserMock;

View File

@@ -1,4 +1,4 @@
const userPayload = (currentUser, role) => {
const getUserMock = (currentUser, role) => {
return {
data: {
createdAt: currentUser.createdAt.toISOString(),
@@ -28,4 +28,4 @@ const userPayload = (currentUser, role) => {
};
};
export default userPayload;
export default getUserMock;