Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .github/workflows/pr-ai-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:

jobs:
pr-ai-description:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
if: false # 임시 비활성화 — 원래 조건: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
timeout-minutes: 15

Expand Down
22 changes: 22 additions & 0 deletions src/common/utils/date-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ describe('date-parser', () => {
const date = new Date('2024-01-01');
expect(toDate(date)).toBe(date);
});

it('빈 문자열이면 BadRequestException을 던져야 한다', () => {
expect(() => toDate('')).toThrow(BadRequestException);
});

it('타임존이 포함된 ISO 문자열이면 Date를 반환해야 한다', () => {
const result = toDate('2024-01-01T00:00:00Z');
expect(result).toBeInstanceOf(Date);
expect(result!.toISOString()).toBe('2024-01-01T00:00:00.000Z');
});

it('앞뒤 공백이 있는 날짜 문자열이면 Date를 반환해야 한다', () => {
const result = toDate(' 2024-01-01 ');
expect(result).toBeInstanceOf(Date);
});

it('Unix epoch(new Date(0))을 그대로 반환해야 한다', () => {
const epoch = new Date(0);
const result = toDate(epoch);
expect(result).toBe(epoch);
expect(result!.getTime()).toBe(0);
});
});

describe('toDateRequired', () => {
Expand Down
16 changes: 16 additions & 0 deletions src/common/utils/text-cleaner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ describe('text-cleaner', () => {
it('유효한 텍스트를 트림하여 반환해야 한다', () => {
expect(cleanRequiredText(' hello ', 100)).toBe('hello');
});

it('정확히 maxLength와 같은 길이면 통과해야 한다', () => {
expect(cleanRequiredText('12345', 5)).toBe('12345');
});

it('maxLength를 1만큼 초과하면 BadRequestException을 던져야 한다', () => {
expect(() => cleanRequiredText('123456', 5)).toThrow(BadRequestException);
});

it('앞뒤 공백을 제거한 결과를 반환해야 한다', () => {
expect(cleanRequiredText(' hello ', 100)).toBe('hello');
});
});

describe('cleanNullableText', () => {
Expand All @@ -48,5 +60,9 @@ describe('text-cleaner', () => {
it('유효한 텍스트를 트림하여 반환해야 한다', () => {
expect(cleanNullableText(' hello ', 100)).toBe('hello');
});

it('탭/개행/캐리지리턴만 있으면 null을 반환해야 한다', () => {
expect(cleanNullableText('\t\n\r', 100)).toBeNull();
});
});
});
Loading
Loading