import assert from 'node:assert/strict';
import test from 'node:test';
import { SECURITY_TIERS, securityTierSatisfies } from '../src/index';

test('security tiers form a deliberate minimum-requirement ordering', () => {
  const expected: Record<(typeof SECURITY_TIERS)[number], (typeof SECURITY_TIERS)[number][]> = {
    community_cloud: ['community_cloud', 'secure_cloud', 'government'],
    secure_cloud: ['secure_cloud', 'government'],
    government: ['government'],
  };

  for (const required of SECURITY_TIERS) {
    const eligible = SECURITY_TIERS.filter((available) =>
      securityTierSatisfies(available, required),
    );
    assert.deepEqual(eligible.sort(), expected[required].sort());
  }
});

test('a sovereign requirement is never satisfied by community capacity', () => {
  assert.equal(securityTierSatisfies('community_cloud', 'government'), false);
  assert.equal(securityTierSatisfies('secure_cloud', 'government'), false);
  assert.equal(securityTierSatisfies('government', 'government'), true);
});
