import { Reflector } from '@nestjs/core';
import { PERMISSION_METADATA_KEY } from '../../common/auth/permission.decorator';
import { ConsistencyController } from './consistency.controller';

describe('ConsistencyController', () => {
  it('requires consistency:view for consistency checks', () => {
    const metadata = new Reflector().get(PERMISSION_METADATA_KEY, ConsistencyController.prototype.run);

    expect(metadata).toEqual({ permission: 'consistency:view' });
  });

  it('delegates consistency checks to the service', async () => {
    const service = { run: jest.fn().mockResolvedValue({ status: 'pass' }) };
    const controller = new ConsistencyController(service as any);

    await expect(controller.run()).resolves.toEqual({ status: 'pass' });
    expect(service.run).toHaveBeenCalledWith();
  });
});
