import { describe, it, expect } from 'vitest';
import { hasProgress, initial, RegistratieState } from './registratie-wizard.machine';

const invullen = (over: Partial<Extract<RegistratieState, { tag: 'Invullen' }>>) => ({
  ...(initial as Extract<RegistratieState, { tag: 'Invullen' }>),
  ...over,
});

describe('hasProgress', () => {
  it('is false for a fresh wizard', () => {
    expect(hasProgress(initial as Extract<RegistratieState, { tag: 'Invullen' }>)).toBe(false);
  });

  it('ignores an auto-prefilled BRP address at step 0', () => {
    const s = invullen({
      draft: {
        straat: 'Lange Voorhout 9',
        postcode: '2514 EA',
        woonplaats: 'Den Haag',
        adresHerkomst: 'brp',
        antwoorden: {},
      },
    });
    expect(hasProgress(s)).toBe(false);
  });

  it('is true once the user advances, picks correspondence/diploma, or is past step 0', () => {
    expect(hasProgress(invullen({ cursor: 1 }))).toBe(true);
    expect(hasProgress(invullen({ draft: { correspondentie: 'post', antwoorden: {} } }))).toBe(
      true,
    );
    expect(hasProgress(invullen({ draft: { diplomaId: 'd1', antwoorden: {} } }))).toBe(true);
  });
});
