Skip to content

Commit

Permalink
테스트오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
neverlish committed Jun 23, 2023
1 parent cce8b89 commit c33b3b6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 49 deletions.
16 changes: 5 additions & 11 deletions tests/test_integral/perfume.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ import {
import {
DEFAULT_RECOMMEND_REQUEST_SIZE,
DEFAULT_RECENT_ADDED_PERFUME_REQUEST_SIZE,
DEFAULT_RECOMMEND_COMMON_REQUEST_SIZE,
DEFAULT_OP_CODE,
} from '@utils/constants';

import { ResponseDTO, SimpleResponseDTO } from '@response/common';
import { OpCode, ResponseDTO, SimpleResponseDTO } from '@response/common';
import {
PerfumeResponse,
PerfumeDetailResponse,
Expand Down Expand Up @@ -180,12 +178,8 @@ describe('# Perfume Integral Test', () => {
expect(responseDTO.message).to.be.eq(
MSG_GET_RECOMMEND_PERFUME_BY_AGE_AND_GENDER
);
expect(responseDTO.data.count).to.be.gte(
DEFAULT_RECOMMEND_COMMON_REQUEST_SIZE
);
expect(responseDTO.data.rows.length).to.be.eq(
DEFAULT_RECOMMEND_COMMON_REQUEST_SIZE
);
expect(responseDTO.data.count).to.be.gte(12);
expect(responseDTO.data.rows.length).to.be.eq(12);
done();
})
.catch((err: Error) => done(err));
Expand Down Expand Up @@ -356,7 +350,7 @@ describe('# Perfume Integral Test', () => {
expect(responseDTO.message).to.be.eq(
MSG_POST_PERFUME_RECOMMEND_SIMMILAR_SUCCESS
);
expect(responseDTO.opcode).to.be.eq(DEFAULT_OP_CODE);
expect(responseDTO.opcode).to.be.eq(OpCode.NONE);
});

it('read success case', async () => {
Expand All @@ -373,7 +367,7 @@ describe('# Perfume Integral Test', () => {
MSG_GET_RECOMMEND_SIMILAR_PERFUMES
);
expect(responseDTO.data.count).to.be.eq(3);
expect(responseDTO.opcode).to.be.eq(DEFAULT_OP_CODE);
expect(responseDTO.opcode).to.be.eq(OpCode.NONE);
});
});
});
Expand Down
7 changes: 3 additions & 4 deletions tests/test_unit/controller/Perfume.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ import {
import {
DEFAULT_RECOMMEND_REQUEST_SIZE,
DEFAULT_RECENT_ADDED_PERFUME_REQUEST_SIZE,
DEFAULT_OP_CODE,
} from '@utils/constants';

import JwtController from '@libs/JwtController';

import { ResponseDTO, SimpleResponseDTO } from '@response/common';
import { OpCode, ResponseDTO, SimpleResponseDTO } from '@response/common';
import {
PerfumeResponse,
PerfumeDetailResponse,
Expand Down Expand Up @@ -487,7 +486,7 @@ describe('# Perfume Controller Test', () => {
expect(responseDTO.message).to.be.eq(
MSG_POST_PERFUME_RECOMMEND_SIMMILAR_SUCCESS
);
expect(responseDTO.opcode).to.be.eq(DEFAULT_OP_CODE);
expect(responseDTO.opcode).to.be.eq(OpCode.NONE);
});

it('read success case', async () => {
Expand Down Expand Up @@ -515,7 +514,7 @@ describe('# Perfume Controller Test', () => {
expect(responseDTO.data.count).to.be.eq(
DEFAULT_RECOMMEND_REQUEST_SIZE
);
expect(responseDTO.opcode).to.be.eq(DEFAULT_OP_CODE);
expect(responseDTO.opcode).to.be.eq(OpCode.NONE);
});
});
});
Expand Down
19 changes: 8 additions & 11 deletions tests/test_unit/controller/User.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
TokenPayloadDTO,
UserAuthDTO,
UserDTO,
TokenGroupDTO,
LoginInfoDTO,
} from '@dto/index';

Expand All @@ -54,16 +53,14 @@ const invalidToken =

describe('# User Controller Test', () => {
describe('# registerUser Test', () => {
mockUserService.createUser = async (): Promise<TokenGroupDTO> =>
TokenGroupDTO.createByJSON(
Object.assign(
{
userIdx: 1,
token: 'token',
refreshToken: 'refreshToken',
},
{}
)
mockUserService.createUser = async (): Promise<object> =>
Object.assign(
{
userIdx: 1,
token: 'token',
refreshToken: 'refreshToken',
},
{}
);
it('success case', (done: Done) => {
request(app)
Expand Down
10 changes: 3 additions & 7 deletions tests/test_unit/dao/ReviewDao.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ dotenv.config();

import ReviewDao from '@dao/ReviewDao';
import KeywordDao from '@dao/KeywordDao';
import { ACCESS_PUBLIC, ACCESS_PRIVATE } from '@utils/constants';

const chai = require('chai');
const { expect } = chai;
Expand Down Expand Up @@ -117,10 +116,7 @@ describe('# reviewDao Test', () => {
expect(review.sillage).to.be.ok;
expect(review.seasonal).to.be.ok;
expect(review.gender).to.be.ok;
expect(review.access).to.be.oneOf([
ACCESS_PRIVATE,
ACCESS_PUBLIC,
]);
expect(review.access).to.be.oneOf([0, 1]);
expect(review.content).to.be.ok;
expect(review.likeCnt).to.be.ok;
expect(review.perfumeIdx).to.be.ok;
Expand Down Expand Up @@ -167,7 +163,7 @@ describe('# reviewDao Test', () => {
expect(review.sillage).to.be.not.undefined;
expect(review.seasonal).to.be.not.undefined;
expect(review.gender).to.be.not.undefined;
expect(review.access).to.be.eq(ACCESS_PUBLIC);
expect(review.access).to.be.eq(1);
expect(review.content).to.be.ok;

expect(review.User).to.be.ok;
Expand Down Expand Up @@ -208,7 +204,7 @@ describe('# reviewDao Test', () => {
expect(result).to.be.ok;
expect(result.length).to.be.eq(5);
result.forEach((it) => {
expect(it.access).to.be.gte(ACCESS_PRIVATE);
expect(it.access).to.be.gte(0);
});
done();
})
Expand Down
16 changes: 5 additions & 11 deletions tests/test_unit/service/PerfumeService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ dotenv.config();

import PerfumeService from '@services/PerfumeService';

import {
ACCESS_PRIVATE,
ACCESS_PUBLIC,
GENDER_MAN,
GENDER_WOMAN,
GRADE_USER,
} from '@utils/constants';
import { GENDER_MAN, GENDER_WOMAN, GRADE_USER } from '@utils/constants';

import {
ListAndCountDTO,
Expand Down Expand Up @@ -81,7 +75,7 @@ describe('# Perfume Service Test', () => {
sillage: SillageProperty.light.value,
seasonal: SeasonalProperty.fall.value,
gender: GenderProperty.male.value,
access: ACCESS_PUBLIC,
access: 1,
content: '시향노트1',
createdAt: '2021-09-26T08:38:33.000Z',
User: {
Expand All @@ -103,7 +97,7 @@ describe('# Perfume Service Test', () => {
sillage: SillageProperty.light.value,
seasonal: SeasonalProperty.fall.value,
gender: GenderProperty.male.value,
access: ACCESS_PRIVATE,
access: 0,
content: '시향노트1',
createdAt: '2021-09-26T08:38:33.000Z',
User: {
Expand Down Expand Up @@ -179,7 +173,7 @@ describe('# Perfume Service Test', () => {
sillage: SillageProperty.light.value,
seasonal: SeasonalProperty.fall.value,
gender: GenderProperty.male.value,
access: ACCESS_PUBLIC,
access: 1,
content: '시향노트1',
createdAt: '2021-09-26T08:38:33.000Z',
User: {
Expand All @@ -201,7 +195,7 @@ describe('# Perfume Service Test', () => {
sillage: SillageProperty.light.value,
seasonal: SeasonalProperty.fall.value,
gender: GenderProperty.male.value,
access: ACCESS_PRIVATE,
access: 1,
content: '시향노트1',
createdAt: '2021-09-26T08:38:33.000Z',
User: {
Expand Down
9 changes: 4 additions & 5 deletions tests/test_unit/service/UserService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotenv.config();

import { WrongPasswordError, PasswordPolicyError } from '@errors';

import { TokenGroupDTO, LoginInfoDTO } from '@dto/index';
import { LoginInfoDTO } from '@dto/index';

import UserService from '@services/UserService';

Expand Down Expand Up @@ -49,16 +49,15 @@ class MockGenerator {
describe('▣ UserService', () => {
describe('▶ create Test', () => {
describe('# method: createUser', () => {
new TestSingle<TokenGroupDTO>(
new TestSingle(
'common',
userService.createUser,
[{}],
(result: TokenGroupDTO | null, err: any, _: any[]) => {
(result, err: any, _: any[]) => {
expect(result).to.be.not.null;
expect(err).to.be.eq(null);

const token: TokenGroupDTO = result!!;
expect(token).to.be.instanceOf(TokenGroupDTO);
const token = result!!;
expect(token.userIdx).to.be.ok;
expect(token.token).to.be.ok;
expect(token.refreshToken).to.be.ok;
Expand Down

0 comments on commit c33b3b6

Please sign in to comment.