import { describe, expect, it } from 'vitest';
import { ensureDrawerClosedForRoute } from '../vault-drawer';

describe('ensureDrawerClosedForRoute', () => {
  it('closes the drawer when navigating to trash', () => {
    const state = { drawerOpen: true };
    ensureDrawerClosedForRoute(state, { view: 'trash' });
    expect(state.drawerOpen).toBe(false);
  });

  it('leaves the drawer open when navigating to detail', () => {
    const state = { drawerOpen: true };
    ensureDrawerClosedForRoute(state, { view: 'detail' });
    expect(state.drawerOpen).toBe(true);
  });

  it('leaves the drawer open in list view', () => {
    const state = { drawerOpen: true };
    ensureDrawerClosedForRoute(state, { view: 'list' });
    expect(state.drawerOpen).toBe(true);
  });

  it('does nothing when the drawer is already closed', () => {
    const state = { drawerOpen: false };
    ensureDrawerClosedForRoute(state, { view: 'devices' });
    expect(state.drawerOpen).toBe(false);
  });
});
