import { describe, it, expect } from 'vitest';
import { emitS2ReadReplacementDev, emitS2ReadReplacementBuild } from './codegen.js';
describe('codegen', () => {
    it('emitS2ReadReplacementDev sets input=sql and embeds SQLs', () => {
        const code = emitS2ReadReplacementDev({
            paramsSrc: '{ id }',
            sqls: ['select 1'],
            isSelects: [true],
            endpointExpr: '"/api/read"',
            debounceMsExpr: '100',
            headersRuntimeExpr: 'undefined',
            callbackRuntimeExpr: 'null'
        });
        expect(code).toContain("input: 'sql'");
        expect(code).toContain(JSON.stringify(['select 1']));
        expect(code).toContain(JSON.stringify([true]));
    });
    it('emitS2ReadReplacementBuild sets input=token and embeds tokens', () => {
        const code = emitS2ReadReplacementBuild({
            paramsSrc: '{ id }',
            tokens: ['AbCdEf'],
            isSelects: [true],
            endpointExpr: '"/api/read"',
            debounceMsExpr: '100',
            headersRuntimeExpr: 'undefined',
            callbackRuntimeExpr: 'null'
        });
        expect(code).toContain("input: 'token'");
        expect(code).toContain(JSON.stringify(['AbCdEf']));
        expect(code).toContain(JSON.stringify([true]));
    });
});
