Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXzpsZQxKG9hQmNRfZjRS
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { formatDate, formatPrice, getDDays } from './realEstateUtils.js';
|
|
|
|
describe('formatPrice', () => {
|
|
it('만원 표기 / falsy → -', () => {
|
|
expect(formatPrice(4500)).toBe('4,500만원');
|
|
expect(formatPrice(0)).toBe('-');
|
|
expect(formatPrice(null)).toBe('-');
|
|
});
|
|
});
|
|
|
|
describe('getDDays (오늘 기준)', () => {
|
|
const iso = (off) => {
|
|
const d = new Date(); d.setHours(0,0,0,0); d.setDate(d.getDate() + off);
|
|
const p = (n) => String(n).padStart(2, '0');
|
|
return `${d.getFullYear()}-${p(d.getMonth()+1)}-${p(d.getDate())}`;
|
|
};
|
|
it('오늘=D-Day, 미래=D-N, 과거=D+N, null→null', () => {
|
|
expect(getDDays(iso(0))).toBe('D-Day');
|
|
expect(getDDays(iso(4))).toBe('D-4');
|
|
expect(getDDays(iso(-2))).toBe('D+2');
|
|
expect(getDDays(null)).toBe(null);
|
|
});
|
|
});
|
|
|
|
describe('formatDate', () => {
|
|
it('유효 날짜 한국어 포맷 / falsy → -', () => {
|
|
expect(formatDate('2026-04-10')).toContain('2026');
|
|
expect(formatDate(null)).toBe('-');
|
|
});
|
|
});
|