Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE/#606] user service 테스트 코드 작성 #607

Merged
merged 8 commits into from
Jan 14, 2024
Prev Previous commit
Next Next commit
[BE] Test : updateUserById 테스트
koomin1227 committed Jan 12, 2024
commit f093c7f9170dab7d37c1185bc252bcaed155f384
52 changes: 52 additions & 0 deletions BE/src/users/users.service.spec.ts
Original file line number Diff line number Diff line change
@@ -96,4 +96,56 @@ describe('UsersService', function () {
expect(res.profile_img).toEqual('default image');
});
});

describe('updateUserById', function () {
it('should update only nickname', async function () {
const nickname = 'test';
const imageLocation = null;
const userId = 'user';
const updateEntity = new UserEntity();
updateEntity.nickname = nickname;
updateEntity.profile_img = undefined;
await service.updateUserById(nickname, imageLocation, userId);
expect(repository.getRepository().update).toHaveBeenCalledWith(
{
user_hash: userId,
},
updateEntity,
);
});

it('should update only image', async function () {
const nickname = null;
const imageLocation = 'test';
const userId = 'user';
const updateEntity = new UserEntity();
updateEntity.nickname = undefined;
updateEntity.profile_img = imageLocation;
await service.updateUserById(nickname, imageLocation, userId);
expect(repository.getRepository().update).toHaveBeenCalledWith(
{
user_hash: userId,
},
updateEntity,
);
});

it('should update all', async function () {
const nickname = 'test';
const imageLocation = 'test';
const userId = 'user';
const updateEntity = new UserEntity();
updateEntity.nickname = nickname;
updateEntity.profile_img = imageLocation;
await service.updateUserById(nickname, imageLocation, userId);
expect(repository.getRepository().update).toHaveBeenCalledWith(
{
user_hash: userId,
},
updateEntity,
);
});
});

describe('', function () {});
});