Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.5 KB
Raw Blame
import type { TFunction } from 'i18next';
import { describe, expect, it } from 'vitest';

import { formatAcceptanceCountsText, resolveAcceptanceVerdictMeta } from './verdict';

const t = ((key: string) => key) as TFunction<'verify'>;

describe('resolveAcceptanceVerdictMeta', () => {
  it('treats repairing as an in-progress task, not a settled verdict', () => {
    const meta = resolveAcceptanceVerdictMeta('repairing', t);
    expect(meta.label).toBe('acceptance.status.repairing');
    expect(meta.spin).toBe(true);
  });

  it('treats accepted as a terminal success', () => {
    expect(resolveAcceptanceVerdictMeta('accepted', t).label).toBe('acceptance.status.accepted');
  });
});

describe('statuses that used to fall through to the generic in-progress pill', () => {
  it('names a delivered acceptance as waiting on the reviewer, without a spinner', () => {
    const meta = resolveAcceptanceVerdictMeta('delivered', t);
    expect(meta.label).toBe('acceptance.status.delivered');
    expect(meta.spin).toBeUndefined();
  });

  it('names a failed verification instead of calling it in progress', () => {
    expect(resolveAcceptanceVerdictMeta('failed', t).label).toBe('acceptance.status.failed');
  });
});

describe('formatAcceptanceCountsText', () => {
  it('joins only the counts that are present', () => {
    expect(
      formatAcceptanceCountsText(t, { failed: 1, notExecuted: 0, passed: 3, uncertain: 0 }),
    ).toBe('acceptance.stats.passed · acceptance.stats.failed');
  });
});