import { describe, expect, it } from 'vitest'; // @ts-expect-error -- .mjs 스크립트라 타입 선언이 없다 (codegen 파이프라인 전용) import { convertToCamelCase, toCamel } from './convertToCamelCase.mjs'; describe('toCamel', () => { it('snake_case를 camelCase로 바꾼다', () => { expect(toCamel('user_id')).toBe('userId'); }); it('이미 camelCase면 그대로 둔다', () => { expect(toCamel('userId')).toBe('userId'); }); }); describe('convertToCamelCase', () => { it('interface 프로퍼티명을 camelCase로 바꾼다', () => { const source = 'export interface Post {\n user_id: number;\n created_at: string;\n}\n'; expect(convertToCamelCase(source)).toBe( 'export interface Post {\n userId: number;\n createdAt: string;\n}\n' ); }); it('이미 camelCase인 스펙에는 아무것도 바꾸지 않는다', () => { const source = 'export interface Post {\n userId: number;\n}\n'; expect(convertToCamelCase(source)).toBe(source); }); it('타입 이름이나 문자열 값은 건드리지 않는다', () => { const source = 'export type Get_Params = {\n user_id: number;\n};\n'; expect(convertToCamelCase(source)).toContain('Get_Params'); expect(convertToCamelCase(source)).toContain('userId'); }); });