- Implemented AlertDialog component with overlay, content, header, footer, title, description, action, and cancel functionalities. - Created Badge component with variant support for different styles. - Developed Checkbox component with custom styling and indicator. - Added Dialog component with trigger, close, overlay, content, header, footer, title, and description. - Introduced Label component for form elements. - Built Select component with trigger, content, group, item, label, separator, and scroll buttons. - Created Sheet component with trigger, close, overlay, content, header, footer, title, and description. - Implemented Table component with header, body, footer, row, head, cell, and caption. - Added Textarea component with custom styling. - Established API service for game management with CRUD operations and metadata search functionalities. - Updated dependencies in package lock files.
104 lines
4.2 KiB
JavaScript
104 lines
4.2 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || (function () {
|
|
var ownKeys = function(o) {
|
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
var ar = [];
|
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
return ar;
|
|
};
|
|
return ownKeys(o);
|
|
};
|
|
return function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const vitest_1 = require("vitest");
|
|
vitest_1.vi.mock('../../src/services/igdbClient', () => ({
|
|
searchGames: vitest_1.vi.fn(),
|
|
getGameById: vitest_1.vi.fn(),
|
|
}));
|
|
vitest_1.vi.mock('../../src/services/rawgClient', () => ({
|
|
searchGames: vitest_1.vi.fn(),
|
|
getGameById: vitest_1.vi.fn(),
|
|
}));
|
|
vitest_1.vi.mock('../../src/services/thegamesdbClient', () => ({
|
|
searchGames: vitest_1.vi.fn(),
|
|
getGameById: vitest_1.vi.fn(),
|
|
}));
|
|
const igdb = __importStar(require("../../src/services/igdbClient"));
|
|
const rawg = __importStar(require("../../src/services/rawgClient"));
|
|
const tgdb = __importStar(require("../../src/services/thegamesdbClient"));
|
|
const metadataService_1 = require("../../src/services/metadataService");
|
|
(0, vitest_1.describe)('services/metadataService', () => {
|
|
(0, vitest_1.beforeEach)(() => {
|
|
vitest_1.vi.clearAllMocks();
|
|
});
|
|
(0, vitest_1.it)('prioriza IGDB cuando hay resultados', async () => {
|
|
igdb.searchGames.mockResolvedValue([
|
|
{
|
|
id: 11,
|
|
name: 'Sonic',
|
|
slug: 'sonic',
|
|
releaseDate: '1991-06-23',
|
|
genres: ['Platform'],
|
|
coverUrl: 'http://img',
|
|
source: 'igdb',
|
|
},
|
|
]);
|
|
rawg.searchGames.mockResolvedValue([]);
|
|
tgdb.searchGames.mockResolvedValue([]);
|
|
const res = await (0, metadataService_1.enrichGame)({ title: 'Sonic' });
|
|
(0, vitest_1.expect)(res).not.toBeNull();
|
|
(0, vitest_1.expect)(res?.source).toBe('igdb');
|
|
(0, vitest_1.expect)(res?.externalIds.igdb).toBe(11);
|
|
(0, vitest_1.expect)(res?.title).toBe('Sonic');
|
|
});
|
|
(0, vitest_1.it)('cae a RAWG cuando IGDB no responde resultados', async () => {
|
|
igdb.searchGames.mockResolvedValue([]);
|
|
rawg.searchGames.mockResolvedValue([
|
|
{
|
|
id: 22,
|
|
name: 'Sonic (rawg)',
|
|
slug: 'sonic-rawg',
|
|
releaseDate: '1991-06-23',
|
|
genres: ['Platform'],
|
|
coverUrl: 'http://img',
|
|
source: 'rawg',
|
|
},
|
|
]);
|
|
tgdb.searchGames.mockResolvedValue([]);
|
|
const res = await (0, metadataService_1.enrichGame)({ title: 'Sonic' });
|
|
(0, vitest_1.expect)(res).not.toBeNull();
|
|
(0, vitest_1.expect)(res?.source).toBe('rawg');
|
|
(0, vitest_1.expect)(res?.externalIds.rawg).toBe(22);
|
|
});
|
|
(0, vitest_1.it)('retorna null si no hay resultados en ninguna API', async () => {
|
|
igdb.searchGames.mockResolvedValue([]);
|
|
rawg.searchGames.mockResolvedValue([]);
|
|
tgdb.searchGames.mockResolvedValue([]);
|
|
const res = await (0, metadataService_1.enrichGame)({ title: 'Juego inexistente' });
|
|
(0, vitest_1.expect)(res).toBeNull();
|
|
});
|
|
});
|