import { describe, expect, it } from 'vitest';
import { filterTabsByPermission } from './permission-tabs';

const tabs = [
  { key: 'records', requiredPermission: 'deposit:view' },
  { key: 'refund', requiredPermission: 'deposit:refund' },
];

describe('permission tabs', () => {
  it('shows only tabs allowed by exact permissions', () => {
    expect(filterTabsByPermission(tabs, ['deposit:view']).map((tab) => tab.key)).toEqual([
      'records',
    ]);
    expect(
      filterTabsByPermission(tabs, ['deposit:view', 'deposit:refund']).map((tab) => tab.key),
    ).toEqual(['records', 'refund']);
  });
});
