Skip to content

Commit cddbfbb

Browse files
committed
refactor: stringToDate를 parseRecruitmentDateString으로 변경
1 parent e7efb5c commit cddbfbb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

frontend/src/utils/stringToDate.test.ts renamed to frontend/src/utils/recruitmentPeriodParser.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
import { stringToDate } from './stringToDate';
1+
import { parseRecruitmentDateString } from './recruitmentPeriodParser.ts';
22

3-
describe('stringToDate 함수 테스트', () => {
3+
describe('parseRecruitmentPeriod 함수 테스트', () => {
44
it('날짜와 시간이 포함된 문자열을 Date 객체로 정확히 바꾼다', () => {
55
const input = '2025.05.25 13:45';
66
const result = new Date('2025-05-25T13:45:00');
7-
expect(stringToDate(input)).toEqual(result);
7+
expect(parseRecruitmentDateString(input)).toEqual(result);
88
});
99

1010
it('자정 시간 "YYYY.MM.DD 00:00" 형식을 올바르게 Date 객체로 변환한다', () => {
1111
const input = '2025.05.25 00:00';
1212
const result = new Date('2025-05-25T00:00:00');
13-
expect(stringToDate(input)).toEqual(result);
13+
expect(parseRecruitmentDateString(input)).toEqual(result);
1414
});
1515

1616
it('공백이 없는 문자열이라면 예외가 발생한다.', () => {
1717
const input = '2025.05.2513:45';
18-
expect(() => stringToDate(input)).toThrow(
18+
expect(() => parseRecruitmentDateString(input)).toThrow(
1919
'유효하지 않은 날짜 형식입니다. 형식은 "YYYY.MM.DD HH:mm" 이어야 합니다.',
2020
);
2121
});
2222

2323
it('시간 부분이 누락된 경우 예외가 발생한다', () => {
2424
const input = '2025.05.25 ';
25-
expect(() => stringToDate(input)).toThrow(
25+
expect(() => parseRecruitmentDateString(input)).toThrow(
2626
'유효하지 않은 날짜 형식입니다. 형식은 "YYYY.MM.DD HH:mm" 이어야 합니다.',
2727
);
2828
});
2929

3030
it('날짜 부분이 누락된 경우 예외가 발생한다', () => {
3131
const input = ' 13:45';
32-
expect(() => stringToDate(input)).toThrow(
32+
expect(() => parseRecruitmentDateString(input)).toThrow(
3333
'유효하지 않은 날짜 형식입니다. 형식은 "YYYY.MM.DD HH:mm" 이어야 합니다.',
3434
);
3535
});
3636

3737
it('빈 문자열이 주어지면 예외가 발생한다', () => {
3838
const input = '';
39-
expect(() => stringToDate(input)).toThrow(
39+
expect(() => parseRecruitmentDateString(input)).toThrow(
4040
'유효하지 않은 날짜 형식입니다. 형식은 "YYYY.MM.DD HH:mm" 이어야 합니다.',
4141
);
4242
});
4343

4444
it('YYYY.MM.DD HH:mm 형식이 아닌 입력에 대해 에러를 던진다', () => {
4545
const input = '1.1.1 1:1';
46-
expect(() => stringToDate(input)).toThrow(
46+
expect(() => parseRecruitmentDateString(input)).toThrow(
4747
'유효하지 않은 날짜 형식입니다. 형식은 "YYYY.MM.DD HH:mm" 이어야 합니다.',
4848
);
4949
});

frontend/src/utils/stringToDate.ts renamed to frontend/src/utils/recruitmentPeriodParser.ts.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { parse, isValid } from 'date-fns';
22

3-
export const stringToDate = (s: string): Date => {
3+
export const parseRecruitmentDateString = (s: string): Date => {
44
const regex = /^\d{4}\.\d{2}\.\d{2} \d{2}:\d{2}$/;
55
if (!regex.test(s)) {
66
throw new Error(
@@ -25,7 +25,7 @@ export const parseRecruitmentPeriod = (
2525
}
2626

2727
return {
28-
recruitmentStart: stringToDate(parts[0]),
29-
recruitmentEnd: stringToDate(parts[1]),
28+
recruitmentStart: parseRecruitmentDateString(parts[0]),
29+
recruitmentEnd: parseRecruitmentDateString(parts[1]),
3030
};
3131
};

0 commit comments

Comments
 (0)