integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { MediaTestContext } from '../MediaTestContext';
|
||||
import { InMemoryLeagueRepository } from '@adapters/racing/persistence/inmemory/InMemoryLeagueRepository';
|
||||
import { League } from '@core/racing/domain/entities/League';
|
||||
import { MediaReference } from '@core/domain/media/MediaReference';
|
||||
|
||||
describe('League Media Management', () => {
|
||||
let ctx: MediaTestContext;
|
||||
let leagueRepository: InMemoryLeagueRepository;
|
||||
|
||||
beforeEach(() => {
|
||||
ctx = MediaTestContext.create();
|
||||
ctx.reset();
|
||||
leagueRepository = new InMemoryLeagueRepository(ctx.logger);
|
||||
});
|
||||
|
||||
it('should upload and set a league logo', async () => {
|
||||
// Given: A league exists
|
||||
const league = League.create({
|
||||
id: 'league-1',
|
||||
name: 'Test League',
|
||||
description: 'Test Description',
|
||||
ownerId: 'owner-1',
|
||||
});
|
||||
await leagueRepository.create(league);
|
||||
|
||||
// When: A logo is uploaded
|
||||
const uploadResult = await ctx.mediaStorage.uploadMedia(
|
||||
Buffer.from('logo content'),
|
||||
{ filename: 'logo.png', mimeType: 'image/png' }
|
||||
);
|
||||
expect(uploadResult.success).toBe(true);
|
||||
const mediaId = 'media-1';
|
||||
|
||||
// And: The league is updated with the new logo reference
|
||||
const updatedLeague = league.update({
|
||||
logoRef: MediaReference.createUploaded(mediaId)
|
||||
});
|
||||
await leagueRepository.update(updatedLeague);
|
||||
|
||||
// Then: The league should have the correct logo reference
|
||||
const savedLeague = await leagueRepository.findById('league-1');
|
||||
expect(savedLeague?.logoRef.type).toBe('uploaded');
|
||||
expect(savedLeague?.logoRef.mediaId).toBe(mediaId);
|
||||
});
|
||||
|
||||
it('should retrieve league media (simulated via repository)', async () => {
|
||||
const league = League.create({
|
||||
id: 'league-1',
|
||||
name: 'Test League',
|
||||
description: 'Test Description',
|
||||
ownerId: 'owner-1',
|
||||
});
|
||||
await leagueRepository.create(league);
|
||||
|
||||
const found = await leagueRepository.findById('league-1');
|
||||
expect(found).not.toBeNull();
|
||||
expect(found?.logoRef).toBeDefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user