We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 107314e commit 5ff1812Copy full SHA for 5ff1812
__test__/sum.test.ts
@@ -4,3 +4,11 @@ import { sum } from '../src/sum';
4
test('add 1+ 2 is 3', () => {
5
expect(sum(1, 2)).toBe(3);
6
});
7
+
8
+test('a값의 상한은 100이다.', () => {
9
+ expect(sum(90, 70)).toBe(160);
10
+});
11
12
+test('a값이 100 이상일 경우 에러가 발생한다.', () => {
13
+ expect(() => sum(110, 20)).toThrow('0~100 사이의 값을 입력해주세요.');
14
src/sum.ts
@@ -1,3 +1,7 @@
1
export function sum(a: number, b: number) {
2
+ if (a < 0 || a > 100) {
3
+ throw new Error('0~100 사이의 값을 입력해주세요.');
+ }
return a + b;
}
0 commit comments