From ebbcf06f5b38f466a9fda30cc01f7cc79eb8de0f Mon Sep 17 00:00:00 2001 From: Pengoose Date: Fri, 26 Apr 2024 14:59:00 +0900 Subject: [PATCH 1/3] =?UTF-8?q?test:=20describe=20=EC=84=B8=EB=B6=84?= =?UTF-8?q?=ED=99=94(chosungIncludes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/chosungIncludes.spec.ts | 42 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/chosungIncludes.spec.ts b/src/chosungIncludes.spec.ts index 4d1eee92..f9b8dd61 100644 --- a/src/chosungIncludes.spec.ts +++ b/src/chosungIncludes.spec.ts @@ -1,31 +1,35 @@ import { chosungIncludes } from './chosungIncludes'; describe('chosungIncludes', () => { - it('should return true when "ㅍㄹㅌ" is entered for searching "프론트엔드"', () => { - expect(chosungIncludes('프론트엔드', 'ㅍㄹㅌ')).toBe(true); - }); + describe('초성이 포함되어있다고 판단되는 경우', () => { + it('should return true when "ㅍㄹㅌ" is entered for searching "프론트엔드"', () => { + expect(chosungIncludes('프론트엔드', 'ㅍㄹㅌ')).toBe(true); + }); - it('should return true when "ㅍㄹㅌ" is entered for searching "00프론트엔드"', () => { - expect(chosungIncludes('00프론트엔드', 'ㅍㄹㅌ')).toBe(true); - }); + it('should return true when "ㅍㄹㅌ" is entered for searching "00프론트엔드"', () => { + expect(chosungIncludes('00프론트엔드', 'ㅍㄹㅌ')).toBe(true); + }); - it('should return false when "ㅍㅌ" is entered for searching "프론트엔드"', () => { - expect(chosungIncludes('프론트엔드', 'ㅍㅌ')).toBe(false); - }); + it('should return true when "ㅍㄹㅌㅇㄷㄱㅂㅈ" is entered for searching "프론트엔드 개발자"', () => { + expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷㄱㅂㅈ')).toBe(true); + }); - it('should return true when "ㅍㄹㅌㅇㄷㄱㅂㅈ" is entered for searching "프론트엔드 개발자"', () => { - expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷㄱㅂㅈ')).toBe(true); + it('should return true when "ㅍㄹㅌㅇㄷ ㄱㅂㅈ" is entered for searching "프론트엔드 개발자"', () => { + expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷ ㄱㅂㅈ')).toBe(true); + }); }); - it('should return true when "ㅍㄹㅌㅇㄷ ㄱㅂㅈ" is entered for searching "프론트엔드 개발자"', () => { - expect(chosungIncludes('프론트엔드 개발자', 'ㅍㄹㅌㅇㄷ ㄱㅂㅈ')).toBe(true); - }); + describe('초성이 포함되어있다고 판단되지 않는 경우', () => { + it('should return false when "ㅍㅌ" is entered for searching "프론트엔드"', () => { + expect(chosungIncludes('프론트엔드', 'ㅍㅌ')).toBe(false); + }); - it('should return true when "ㅍㄹㅌㅇㄷ ㄱㅂㅈ" is entered for searching " "', () => { - expect(chosungIncludes('프론트엔드 개발자', ' ')).toBe(false); - }); + it('should return false when "ㅍㄹㅌㅇㄷ ㄱㅂㅈ" is entered for searching " "', () => { + expect(chosungIncludes('프론트엔드 개발자', ' ')).toBe(false); + }); - it('should return false when "푸롴트" is entered for searching "프론트엔드" as it does not only include the initial consonants.', () => { - expect(chosungIncludes('프론트엔드', '푸롴트')).toBe(false); + it('should return false when "푸롴트" is entered for searching "프론트엔드" as it does not only include the initial consonants.', () => { + expect(chosungIncludes('프론트엔드', '푸롴트')).toBe(false); + }); }); }); From dd3363c0aa80cb9829f6471af32ce6b0744d7f53 Mon Sep 17 00:00:00 2001 From: Pengoose Date: Fri, 26 Apr 2024 15:10:31 +0900 Subject: [PATCH 2/3] =?UTF-8?q?test:=20describe=20=EC=84=B8=EB=B6=84?= =?UTF-8?q?=ED=99=94(hangulIncludes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hangulIncludes.spec.ts | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/hangulIncludes.spec.ts b/src/hangulIncludes.spec.ts index 9d5a08fb..451fb4ec 100644 --- a/src/hangulIncludes.spec.ts +++ b/src/hangulIncludes.spec.ts @@ -1,20 +1,30 @@ import { hangulIncludes } from './hangulIncludes'; describe('hangulIncludes', () => { - it('사과', () => { - expect(hangulIncludes('사과', '')).toBe(true); - expect(hangulIncludes('사과', 'ㅅ')).toBe(true); - expect(hangulIncludes('사과', '삭')).toBe(true); - expect(hangulIncludes('사과', '삽')).toBe(false); - expect(hangulIncludes('사과', '사과')).toBe(true); + describe('한글이 포함되어있다고 판단되는 경우', () => { + it('사과', () => { + expect(hangulIncludes('사과', '')).toBe(true); + expect(hangulIncludes('사과', 'ㅅ')).toBe(true); + expect(hangulIncludes('사과', '삭')).toBe(true); + expect(hangulIncludes('사과', '사과')).toBe(true); + }); + + it('프론트엔드', () => { + expect(hangulIncludes('프론트엔드', '')).toBe(true); + expect(hangulIncludes('프론트엔드', '플')).toBe(true); + expect(hangulIncludes('프론트엔드', '틍')).toBe(true); + expect(hangulIncludes('프론트엔드', '플')).toBe(true); + expect(hangulIncludes('프론트엔드', '프로')).toBe(true); + }); }); - it('프론트엔드', () => { - expect(hangulIncludes('프론트엔드', '')).toBe(true); - expect(hangulIncludes('프론트엔드', '플')).toBe(true); - expect(hangulIncludes('프론트엔드', '틍')).toBe(true); - expect(hangulIncludes('프론트엔드', '픏')).toBe(false); - expect(hangulIncludes('프론트엔드', '플')).toBe(true); - expect(hangulIncludes('프론트엔드', '프로')).toBe(true); + describe('한글이 포함되어있다고 판단되지 않는 경우', () => { + it('사과', () => { + expect(hangulIncludes('사과', '삽')).toBe(false); + }); + + it('프론트엔드', () => { + expect(hangulIncludes('프론트엔드', '픏')).toBe(false); + }); }); }); From 952a8ce33abef2ed46d706ace9b4dbb8a24c67b7 Mon Sep 17 00:00:00 2001 From: Pengoose Date: Fri, 26 Apr 2024 16:40:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?test:=20describe=20=EC=84=B8=EB=B6=84?= =?UTF-8?q?=ED=99=94(utils)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils.spec.ts | 167 ++++++++++++++++++++++++++-------------------- 1 file changed, 95 insertions(+), 72 deletions(-) diff --git a/src/utils.spec.ts b/src/utils.spec.ts index b94e565d..789495d7 100644 --- a/src/utils.spec.ts +++ b/src/utils.spec.ts @@ -10,20 +10,25 @@ import { } from './utils'; describe('hasBatchim', () => { - it('should return true for the character "값"', () => { - expect(hasBatchim('값')).toBe(true); - }); - it('should return true for the character "공"', () => { - expect(hasBatchim('공')).toBe(true); - }); - it('should return false for the character "토"', () => { - expect(hasBatchim('토')).toBe(false); - }); - it('should return true for the character "읊"', () => { - expect(hasBatchim('읊')).toBe(true); - }); - it('should return false for the character "서"', () => { - expect(hasBatchim('서')).toBe(false); + describe('받침이 있다고 판단되는 경우', () => { + it('should return true for the character "값"', () => { + expect(hasBatchim('값')).toBe(true); + }); + it('should return true for the character "공"', () => { + expect(hasBatchim('공')).toBe(true); + }); + it('should return true for the character "읊"', () => { + expect(hasBatchim('읊')).toBe(true); + }); + }); + + describe('받침이 없다고 판단되는 경우', () => { + it('should return false for the character "토"', () => { + expect(hasBatchim('토')).toBe(false); + }); + it('should return false for the character "서"', () => { + expect(hasBatchim('서')).toBe(false); + }); }); }); @@ -34,14 +39,17 @@ describe('hasSingleBatchim', () => { expect(hasSingleBatchim('양')).toBe(true); expect(hasSingleBatchim('신')).toBe(true); }); - it('겹받침을 받으면 false를 반환한다.', () => { - expect(hasSingleBatchim('값')).toBe(false); - expect(hasSingleBatchim('읊')).toBe(false); - }); - it('받침이 없는 문자를 받으면 false를 반환한다.', () => { - expect(hasSingleBatchim('토')).toBe(false); - expect(hasSingleBatchim('서')).toBe(false); + describe('홑받침이 아니라고 판단되는 경우', () => { + it('겹받침을 받으면 false를 반환한다.', () => { + expect(hasSingleBatchim('값')).toBe(false); + expect(hasSingleBatchim('읊')).toBe(false); + }); + + it('받침이 없는 문자를 받으면 false를 반환한다.', () => { + expect(hasSingleBatchim('토')).toBe(false); + expect(hasSingleBatchim('서')).toBe(false); + }); }); }); @@ -117,64 +125,79 @@ describe('hasProperty', () => { }); describe('canBeChosung', () => { - it('ㄱ', () => { - expect(canBeChosung('ㄱ')).toBe(true); - }); - it('ㅃ', () => { - expect(canBeChosung('ㅃ')).toBe(true); - }); - it('ㅏ', () => { - expect(canBeChosung('ㅏ')).toBe(false); - }); - it('ㅘ', () => { - expect(canBeChosung('ㅏ')).toBe(false); - }); - it('ㄱㅅ', () => { - expect(canBeChosung('ㅏ')).toBe(false); - }); - it('가', () => { - expect(canBeChosung('ㅏ')).toBe(false); + describe('초성이 될 수 있다고 판단되는 경우', () => { + it('ㄱ', () => { + expect(canBeChosung('ㄱ')).toBe(true); + }); + it('ㅃ', () => { + expect(canBeChosung('ㅃ')).toBe(true); + }); + }); + + describe('초성이 될 수 없다고 판단되는 경우', () => { + it('ㅏ', () => { + expect(canBeChosung('ㅏ')).toBe(false); + }); + it('ㅘ', () => { + expect(canBeChosung('ㅏ')).toBe(false); + }); + it('ㄱㅅ', () => { + expect(canBeChosung('ㅏ')).toBe(false); + }); + it('가', () => { + expect(canBeChosung('ㅏ')).toBe(false); + }); }); }); describe('canBeJungsung', () => { - it('ㅗㅏ', () => { - expect(canBeJungsung('ㅗㅏ')).toBe(true); - }); - it('ㅏ', () => { - expect(canBeJungsung('ㅏ')).toBe(true); - }); - it('ㄱ', () => { - expect(canBeJungsung('ㄱ')).toBe(false); - }); - it('ㄱㅅ', () => { - expect(canBeJungsung('ㄱㅅ')).toBe(false); - }); - it('가', () => { - expect(canBeJungsung('가')).toBe(false); + describe('중성이 될 수 있다고 판단되는 경우', () => { + it('ㅗㅏ', () => { + expect(canBeJungsung('ㅗㅏ')).toBe(true); + }); + it('ㅏ', () => { + expect(canBeJungsung('ㅏ')).toBe(true); + }); + }); + + describe('중성이 될 수 없다고 판단되는 경우', () => { + it('ㄱ', () => { + expect(canBeJungsung('ㄱ')).toBe(false); + }); + it('ㄱㅅ', () => { + expect(canBeJungsung('ㄱㅅ')).toBe(false); + }); + it('가', () => { + expect(canBeJungsung('가')).toBe(false); + }); }); }); describe('canBeJongsung', () => { - it('ㄱ', () => { - expect(canBeJongsung('ㄱ')).toBe(true); - }); - it('ㄱㅅ', () => { - expect(canBeJongsung('ㄱㅅ')).toBe(true); - }); - it('ㅂㅅ', () => { - expect(canBeJongsung('ㅂㅅ')).toBe(true); - }); - it('ㅎㄹ', () => { - expect(canBeJongsung('ㅎㄹ')).toBe(false); - }); - it('ㅗㅏ', () => { - expect(canBeJongsung('ㅗㅏ')).toBe(false); - }); - it('ㅏ', () => { - expect(canBeJongsung('ㅏ')).toBe(false); - }); - it('가', () => { - expect(canBeJongsung('ㅏ')).toBe(false); + describe('종성이 될 수 있다고 판단되는 경우', () => { + it('ㄱ', () => { + expect(canBeJongsung('ㄱ')).toBe(true); + }); + it('ㄱㅅ', () => { + expect(canBeJongsung('ㄱㅅ')).toBe(true); + }); + it('ㅂㅅ', () => { + expect(canBeJongsung('ㅂㅅ')).toBe(true); + }); + }); + + describe('종성이 될 수 없다고 판단되는 경우', () => { + it('ㅎㄹ', () => { + expect(canBeJongsung('ㅎㄹ')).toBe(false); + }); + it('ㅗㅏ', () => { + expect(canBeJongsung('ㅗㅏ')).toBe(false); + }); + it('ㅏ', () => { + expect(canBeJongsung('ㅏ')).toBe(false); + }); + it('가', () => { + expect(canBeJongsung('ㅏ')).toBe(false); + }); }); });