import { describe, it, expect } from 'vitest';
import { SubmitBlocker } from './SubmitBlocker';

describe('SubmitBlocker', () => {
  let blocker: SubmitBlocker;

  beforeEach(() => {
    blocker = new SubmitBlocker();
  });

  it('should allow execution initially', () => {
    expect(blocker.canExecute()).toBe(true);
  });

  it('should block execution after block() is called', () => {
    blocker.block();
    expect(blocker.canExecute()).toBe(false);
  });

  it('should allow execution again after release() is called', () => {
    blocker.block();
    expect(blocker.canExecute()).toBe(false);
    blocker.release();
    expect(blocker.canExecute()).toBe(true);
  });

  it('should handle multiple block/release cycles', () => {
    blocker.block();
    expect(blocker.canExecute()).toBe(false);
    blocker.release();
    expect(blocker.canExecute()).toBe(true);
    blocker.block();
    expect(blocker.canExecute()).toBe(false);
    blocker.release();
    expect(blocker.canExecute()).toBe(true);
  });
});