import { describe, expect, it } from 'vitest';
import { buildDingTalkConfigPayload, isAppSecretRequired } from './integration-config-form';

describe('DingTalk integration config form', () => {
  it('requires AppSecret only for the first configuration', () => {
    expect(isAppSecretRequired(false)).toBe(true);
    expect(isAppSecretRequired(true)).toBe(false);
  });

  it('builds a manual-sync config without the retired startEnable flag', () => {
    expect(
      buildDingTalkConfigPayload({
        corpId: 'ding-corp',
        agentId: 'app-key',
        appSecret: '',
      }),
    ).toEqual({
      corpId: 'ding-corp',
      agentId: 'app-key',
      appSecret: undefined,
    });
  });
});
