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

test: amountToHangul 테스트 추가 #135

Merged
merged 7 commits into from
Jul 3, 2024
Merged

test: amountToHangul 테스트 추가 #135

merged 7 commits into from
Jul 3, 2024

Conversation

fe-dudu
Copy link
Contributor

@fe-dudu fe-dudu commented Jun 25, 2024

Overview

amountToHangul 함수의 error case test를 추가하여 Uncovered Line을 제거합니다.

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

Copy link

changeset-bot bot commented Jun 25, 2024

⚠️ No Changeset found

Latest commit: 0db609b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-hangul ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 3, 2024 6:27am

src/amountToHangul.spec.ts Outdated Show resolved Hide resolved

it('숫자로 된 금액이 80글자를 넘을 시 에러 발생', () => {
const longNumberString = '1'.repeat(81);
assert.throws(() => amountToHangul(longNumberString), Error, `convert range exceeded : ${longNumberString}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 프로젝트에서 사용하는 vitest가 제공해주는 toThrow 메서드가 아닌, assert를 사용하면 어떠한 이점이 있나요?
제가 생각한건 다음과 같아요.

 expect(() => amountToHangul(longNumberString)).toThrow(`convert range exceeded : ${longNumberString}`);
  });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

특별한 이점은 없고 combineHangulCharacter.spec.ts, hangul.spec.ts에서 node 기본 모듈인 assert의 throws 메서드를 사용하다보니 동일하게 사용하려고 했습니다. vitest에서 제공해주는 toThrow 메서드를 사용하는 것이 일관성이 있을 것 같아요 !

combineHangulCharacter.spec.ts, hangul.spec.ts에서도 assert.throws대신 toThrow 메서드를 사용하도록 변경되면 좋을 것 같은데 추가로 PR 올려도 괜찮을까요 ?

Copy link
Contributor

@po4tion po4tion Jun 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okinawaa 님 이건 좀 다른 주제이긴 한데요. vitest에서 제공하는 toThrowtoThrowError의 별칭인데요. 현재 테스트 코드 대다수에서 toThrowError를 사용하고 있는데 하나로 통일하여 일관성을 지키는게 좋지 않을까 싶은데 어떠신가요?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vitest-dev/vitest#2570

두 메서드는 동일하지만 error를 테스트할때 toThrowError를 사용하는 것이 직관적이겠네요 !

okinawaa
okinawaa previously approved these changes Jul 2, 2024
Copy link
Member

@okinawaa okinawaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다

@okinawaa
Copy link
Member

okinawaa commented Jul 3, 2024

conflic해결만 부탁드립니다 @fe-dudu

@okinawaa okinawaa merged commit 9b256b9 into toss:main Jul 3, 2024
9 checks passed
seungrodotlee pushed a commit to seungrodotlee/es-hangul that referenced this pull request Jul 6, 2024
* test: amountToHangul 테스트 추가

* test: amountToHangul 테스트 코드 수정

* test: amountToHangul 테스트 코드 스타일 변경

* test: amountToHangul test 개선

* fix: assert.throws대신 vitest toThrow로 메서드 변경

* fix: vitest toThrowError 메서드로 변경

---------

Co-authored-by: kinndohyun <[email protected]>
Co-authored-by: 박찬혁 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants