feat(reputation): add ReputationService, rank resolver integration, and GET /api/reputation

This commit is contained in:
Bastian Wagner
2026-08-21 09:22:36 +02:00
parent 4c9397336f
commit 79d4e04172
7 changed files with 439 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import request from 'supertest';
import { App } from 'supertest/types';
import { configureApplication } from '../app.config';
import { DEMO_CHARACTER_ID } from '../demo/demo-character.constants';
import { ReputationController } from './reputation.controller';
import { ReputationService } from './reputation.service';
describe('ReputationController', () => {
let app: INestApplication<App>;
const getCharacterReputation = jest.fn();
beforeEach(async () => {
getCharacterReputation.mockReset();
const module = await Test.createTestingModule({
controllers: [ReputationController],
providers: [{ provide: ReputationService, useValue: { getCharacterReputation } }],
}).compile();
app = module.createNestApplication<App>();
configureApplication(app);
await app.init();
});
afterEach(async () => {
await app.close();
});
it('delegates GET /api/reputation to reputationService.getCharacterReputation', async () => {
const entries = [
{
factionKey: 'border-guard',
factionName: 'Grenzwacht',
reputation: 40,
rank: 'STRANGER',
rankLabel: 'Fremder',
nextThreshold: 100,
},
];
getCharacterReputation.mockResolvedValue(entries);
const response = await request(app.getHttpServer()).get('/api/reputation').expect(200);
expect(getCharacterReputation).toHaveBeenCalledWith(DEMO_CHARACTER_ID);
expect(response.body).toEqual(entries);
});
});