import { describe, expect, it } from 'vitest'; import { isChannelAllowed, isRoleAllowed } from './command-gate-rules.js'; describe('command-gates channel rules', () => { it('allows any channel when allow and deny are empty', () => { expect(isChannelAllowed('1', [], [])).toBeNull(); }); it('blocks denied channels even when allow is empty', () => { expect(isChannelAllowed('1', [], ['1'])).toBe('channel_denied'); }); it('requires membership when allow list is set', () => { expect(isChannelAllowed('1', ['2'], [])).toBe('channel_not_allowed'); expect(isChannelAllowed('2', ['2'], [])).toBeNull(); }); it('prefers deny over allow', () => { expect(isChannelAllowed('1', ['1'], ['1'])).toBe('channel_denied'); }); }); describe('command-gates role rules', () => { it('blocks when any denied role is present', () => { expect(isRoleAllowed(['a', 'b'], [], ['b'])).toBe('role_denied'); }); it('requires an allowed role when allow list is set', () => { expect(isRoleAllowed(['a'], ['b'], [])).toBe('role_not_allowed'); expect(isRoleAllowed(['a', 'b'], ['b'], [])).toBeNull(); }); });