- 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.
118 lines
4.9 KiB
JavaScript
118 lines
4.9 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");
|
|
const app_1 = require("../../src/app");
|
|
const metadataService = __importStar(require("../../src/services/metadataService"));
|
|
(0, vitest_1.describe)('Metadata API', () => {
|
|
let app;
|
|
(0, vitest_1.beforeEach)(async () => {
|
|
app = (0, app_1.buildApp)();
|
|
await app.ready();
|
|
});
|
|
(0, vitest_1.afterEach)(async () => {
|
|
await app.close();
|
|
vitest_1.vi.restoreAllMocks();
|
|
});
|
|
(0, vitest_1.describe)('GET /api/metadata/search', () => {
|
|
(0, vitest_1.it)('debería devolver resultados cuando se busca un juego existente', async () => {
|
|
const mockResults = [
|
|
{
|
|
source: 'igdb',
|
|
externalIds: { igdb: 1 },
|
|
title: 'The Legend of Zelda',
|
|
slug: 'the-legend-of-zelda',
|
|
releaseDate: '1986-02-21',
|
|
genres: ['Adventure'],
|
|
coverUrl: 'https://example.com/cover.jpg',
|
|
},
|
|
];
|
|
vitest_1.vi.spyOn(metadataService, 'enrichGame').mockResolvedValue(mockResults[0]);
|
|
const res = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/metadata/search?q=zelda',
|
|
});
|
|
(0, vitest_1.expect)(res.statusCode).toBe(200);
|
|
const body = res.json();
|
|
(0, vitest_1.expect)(Array.isArray(body)).toBe(true);
|
|
(0, vitest_1.expect)(body.length).toBeGreaterThan(0);
|
|
(0, vitest_1.expect)(body[0].title).toContain('Zelda');
|
|
});
|
|
(0, vitest_1.it)('debería devolver lista vacía cuando no hay resultados', async () => {
|
|
vitest_1.vi.spyOn(metadataService, 'enrichGame').mockResolvedValue(null);
|
|
const res = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/metadata/search?q=nonexistentgame12345',
|
|
});
|
|
(0, vitest_1.expect)(res.statusCode).toBe(200);
|
|
const body = res.json();
|
|
(0, vitest_1.expect)(Array.isArray(body)).toBe(true);
|
|
(0, vitest_1.expect)(body.length).toBe(0);
|
|
});
|
|
(0, vitest_1.it)('debería devolver 400 si falta el parámetro query', async () => {
|
|
const res = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/metadata/search',
|
|
});
|
|
(0, vitest_1.expect)(res.statusCode).toBe(400);
|
|
(0, vitest_1.expect)(res.json()).toHaveProperty('error');
|
|
});
|
|
(0, vitest_1.it)('debería devolver 400 si el parámetro query está vacío', async () => {
|
|
const res = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/metadata/search?q=',
|
|
});
|
|
(0, vitest_1.expect)(res.statusCode).toBe(400);
|
|
});
|
|
(0, vitest_1.it)('debería pasar el parámetro platform a enrichGame si se proporciona', async () => {
|
|
const enrichSpy = vitest_1.vi.spyOn(metadataService, 'enrichGame').mockResolvedValue(null);
|
|
const res = await app.inject({
|
|
method: 'GET',
|
|
url: '/api/metadata/search?q=mario&platform=Nintendo%2064',
|
|
});
|
|
(0, vitest_1.expect)(res.statusCode).toBe(200);
|
|
(0, vitest_1.expect)(enrichSpy).toHaveBeenCalledWith({
|
|
title: 'mario',
|
|
platform: 'Nintendo 64',
|
|
});
|
|
});
|
|
});
|
|
});
|
|
/**
|
|
* Metadatos:
|
|
* Autor: GitHub Copilot
|
|
* Última actualización: 2026-02-11
|
|
*/
|