Files
quasar/backend/dist/tests/services/archiveReader.stream.spec.js
Benito Rodríguez a07096d7c7
Some checks failed
CI / lint (push) Failing after 1m5s
CI / test-backend (push) Has been skipped
CI / test-frontend (push) Has been skipped
CI / test-e2e (push) Has been skipped
feat: add UI components for alert dialog, badge, checkbox, dialog, label, select, sheet, table, textarea
- 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.
2026-03-18 19:21:36 +01:00

90 lines
3.7 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 stream_1 = require("stream");
const events_1 = require("events");
vitest_1.vi.mock('child_process', () => ({ spawn: vitest_1.vi.fn() }));
const child_process = __importStar(require("child_process"));
const archiveReader_1 = require("../../src/services/archiveReader");
(0, vitest_1.afterEach)(() => {
vitest_1.vi.restoreAllMocks();
});
(0, vitest_1.describe)('services/archiveReader streamArchiveEntry', () => {
(0, vitest_1.it)('streams entry using 7z stdout', async () => {
const pass = new stream_1.PassThrough();
const proc = new events_1.EventEmitter();
proc.stdout = pass;
child_process.spawn.mockImplementation(() => proc);
// Emular producción de datos de forma asíncrona
setImmediate(() => {
pass.write(Buffer.from('content-from-7z'));
pass.end();
});
const stream = await (0, archiveReader_1.streamArchiveEntry)('/roms/archive.7z', 'path/file.txt');
(0, vitest_1.expect)(stream).not.toBeNull();
const chunks = [];
for await (const chunk of stream) {
chunks.push(Buffer.from(chunk));
}
(0, vitest_1.expect)(Buffer.concat(chunks).toString()).toBe('content-from-7z');
});
(0, vitest_1.it)('falls back to unzip -p when 7z throws', async () => {
const pass = new stream_1.PassThrough();
const proc2 = new events_1.EventEmitter();
proc2.stdout = pass;
child_process.spawn
.mockImplementationOnce(() => {
throw new Error('spawn ENOENT');
})
.mockImplementationOnce(() => proc2);
setImmediate(() => {
pass.write(Buffer.from('fallback-content'));
pass.end();
});
const stream = await (0, archiveReader_1.streamArchiveEntry)('/roms/archive.zip', 'file.dat');
(0, vitest_1.expect)(stream).not.toBeNull();
const chunks = [];
for await (const chunk of stream) {
chunks.push(Buffer.from(chunk));
}
(0, vitest_1.expect)(Buffer.concat(chunks).toString()).toBe('fallback-content');
});
(0, vitest_1.it)('returns null for unsupported formats', async () => {
const res = await (0, archiveReader_1.streamArchiveEntry)('/roms/archive.bin', 'entry');
(0, vitest_1.expect)(res).toBeNull();
});
});