// NOTE: useUnsavedGuard (the React hook) needs a component render and a DOM,
// neither of which exist in this node test environment — so the dirty-state
// paths cannot be registered here. These tests cover the module's exported
// behavior with an empty checker registry, including that window.confirm is
// NOT shown when nothing is dirty.
import { describe, it, expect, vi, afterEach } from 'vitest';
import { hasUnsavedChanges, confirmDiscardUnsaved } from './unsavedGuard';

afterEach(() => {
  vi.unstubAllGlobals();
});

describe('hasUnsavedChanges', () => {
  it('is false when no view registered a checker', () => {
    expect(hasUnsavedChanges()).toBe(false);
  });
});

describe('confirmDiscardUnsaved', () => {
  it('proceeds without prompting when nothing is dirty', () => {
    const confirm = vi.fn().mockReturnValue(false);
    vi.stubGlobal('window', { confirm });
    expect(confirmDiscardUnsaved()).toBe(true);
    expect(confirm).not.toHaveBeenCalled();
  });
});
