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: 테스트 관심사에 따른 describe 세분화 #80

Merged
merged 3 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/chosungIncludes.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
36 changes: 23 additions & 13 deletions src/hangulIncludes.spec.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
167 changes: 95 additions & 72 deletions src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

Expand All @@ -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);
});
});
});

Expand Down Expand Up @@ -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);
});
});
});