From 8f7cc9abf033e8e994543aabef23f5b2e080916b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=8F=84=ED=98=84?= <101170386+fe-dudu@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:38:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9D=BC=EA=B4=80=EB=90=9C=20toThrowErr?= =?UTF-8?q?or=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=82=AC=EC=9A=A9=20(#166)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kinndohyun --- src/_internal/hangul.spec.ts | 24 ++++++++---------------- src/combineHangulCharacter.spec.ts | 8 ++++---- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/_internal/hangul.spec.ts b/src/_internal/hangul.spec.ts index e5307cf0..f09f88b2 100644 --- a/src/_internal/hangul.spec.ts +++ b/src/_internal/hangul.spec.ts @@ -113,27 +113,19 @@ describe('binaryAssembleHangulCharacters', () => { }); it('소스가 두 글자 이상이라면 Invalid source 에러를 발생시킨다.', () => { - assert.throws( - () => binaryAssembleHangulCharacters('가나', 'ㄴ'), - Error, + expect(() => binaryAssembleHangulCharacters('가나', 'ㄴ')).toThrowError( 'Invalid source character: 가나. Source must be one character.' ); - assert.throws( - () => binaryAssembleHangulCharacters('ㄱㄴ', 'ㅏ'), - Error, + expect(() => binaryAssembleHangulCharacters('ㄱㄴ', 'ㅏ')).toThrowError( 'Invalid source character: ㄱㄴ. Source must be one character.' ); }); it('다음 문자가 한글 문자 한 글자가 아니라면 Invalid next character 에러를 발생시킨다.', () => { - assert.throws( - () => binaryAssembleHangulCharacters('ㄱ', 'a'), - Error, + expect(() => binaryAssembleHangulCharacters('ㄱ', 'a')).toThrowError( 'Invalid next character: a. Next character must be one of the chosung, jungsung, or jongsung.' ); - assert.throws( - () => binaryAssembleHangulCharacters('ㄱ', 'ㅡㅏ'), - Error, + expect(() => binaryAssembleHangulCharacters('ㄱ', 'ㅡㅏ')).toThrowError( 'Invalid next character: ㅡㅏ. Next character must be one of the chosung, jungsung, or jongsung.' ); }); @@ -164,10 +156,10 @@ describe('binaryAssembleHangul', () => { describe('assertHangul', () => { it('한글 문자열을 받으면 에러를 발생시키지 않는다.', () => { - expect(() => assertHangul('ㄱ')).not.toThrow(); - expect(() => assertHangul('고양이')).not.toThrow(); - expect(() => assertHangul('저는 고양이를 좋아합니다')).not.toThrow(); - expect(() => assertHangul('저는 고양이를 좋아합니ㄷ')).not.toThrow(); + expect(() => assertHangul('ㄱ')).not.toThrowError(); + expect(() => assertHangul('고양이')).not.toThrowError(); + expect(() => assertHangul('저는 고양이를 좋아합니다')).not.toThrowError(); + expect(() => assertHangul('저는 고양이를 좋아합니ㄷ')).not.toThrowError(); }); it("한글 문자열이 아닌 값을 받으면 '___ is not a valid hangul string' 에러를 발생시킨다.", () => { diff --git a/src/combineHangulCharacter.spec.ts b/src/combineHangulCharacter.spec.ts index 46a666f1..5bd0845c 100644 --- a/src/combineHangulCharacter.spec.ts +++ b/src/combineHangulCharacter.spec.ts @@ -14,19 +14,19 @@ describe('combineHangulCharacter', () => { }); it('초성이 될 수 없는 문자가 초성으로 입력되면 에러를 반환한다. (ㅏ, ㅏ, ㄱ)', () => { - assert.throws(() => combineHangulCharacter('ㅏ', 'ㅏ', 'ㄱ'), Error, 'Invalid hangul Characters: ㅏ, ㅏ, ㄱ'); + expect(() => combineHangulCharacter('ㅏ', 'ㅏ', 'ㄱ')).toThrowError('Invalid hangul Characters: ㅏ, ㅏ, ㄱ'); }); it('중성이 될 수 없는 문자가 중성으로 입력되면 에러를 반환한다. (ㄱ, ㄴ, ㅃ)', () => { - assert.throws(() => combineHangulCharacter('ㄱ', 'ㄴ', 'ㅃ'), Error, 'Invalid hangul Characters: ㄱ, ㄴ, ㅃ'); + expect(() => combineHangulCharacter('ㄱ', 'ㄴ', 'ㅃ')).toThrowError('Invalid hangul Characters: ㄱ, ㄴ, ㅃ'); }); it('종성이 될 수 없는 문자가 종성으로 입력되면 에러를 반환한다. (ㄱ, ㅏ, ㅃ)', () => { - assert.throws(() => combineHangulCharacter('ㄱ', 'ㅏ', 'ㅃ'), Error, 'Invalid hangul Characters: ㄱ, ㅏ, ㅃ'); + expect(() => combineHangulCharacter('ㄱ', 'ㅏ', 'ㅃ')).toThrowError('Invalid hangul Characters: ㄱ, ㅏ, ㅃ'); }); it('온전한 한글 문자가 하나라도 입력되면 에러를 반환한다. (가, ㅏ, ㄱ)', () => { - assert.throws(() => combineHangulCharacter('가', 'ㅏ', 'ㄱ'), Error, 'Invalid hangul Characters: 가, ㅏ, ㄱ'); + expect(() => combineHangulCharacter('가', 'ㅏ', 'ㄱ')).toThrowError('Invalid hangul Characters: 가, ㅏ, ㄱ'); }); });