import { describe, expect, it } from 'vitest' import { readIsHatti, writeIsHatti } from './is-hatti-settings' describe('AITURK iş hattı settings', () => { it('defaults to the recommended rule and reads older files the way the bridge does', () => { expect(readIsHatti(null)).toEqual({ secim: 'onerilen', talimat: '' }) expect(readIsHatti('{"aiturk_hat":{"enabled":false}}').secim).toBe('kapali') expect(readIsHatti('{"aiturk_hat":{"talimat":"x"}}')).toEqual({ secim: 'ozel', talimat: 'x' }) expect(readIsHatti('bozuk').secim).toBe('onerilen') }) it('writes only aiturk_hat and keeps everything else', () => { const raw = '{"port":8795,"aiturk_hat":{"enabled":false,"komut":"k"}}' const out = JSON.parse(writeIsHatti(raw, { secim: 'buyuk', talimat: '' })) expect(out).toEqual({ port: 8795, aiturk_hat: { komut: 'k', secim: 'buyuk', talimat: '' } }) }) it('rejects an empty custom text and unknown choices', () => { expect(() => writeIsHatti(null, { secim: 'ozel', talimat: ' ' })).toThrow() expect(() => writeIsHatti(null, { secim: 'x', talimat: '' })).toThrow() expect(() => writeIsHatti('{bozuk', { secim: 'onerilen', talimat: '' })).toThrow() }) })