Files
electron-universal/test/file-utils.spec.ts
Fedor Indutny 0939980564
Some checks failed
Publish documentation / docs (push) Failing after 13s
fix: fully respect singleArchFiles option (#152)
Files listed under `singleArchFiles` are allowed to be unique for
different platforms so `dupedFiles` should not return them.

Fix: #151
2025-10-29 12:52:59 -04:00

64 lines
2.1 KiB
TypeScript

import * as path from 'node:path';
import { beforeAll, describe, expect, it } from 'vitest';
import { AppFile, AppFileType, getAllAppFiles } from '../src/file-utils.js';
const appsPath = path.resolve(import.meta.dirname, 'fixtures', 'apps');
describe('file-utils', () => {
describe('getAllAppFiles', () => {
let asarFiles: AppFile[];
let noAsarFiles: AppFile[];
beforeAll(async () => {
asarFiles = await getAllAppFiles(path.resolve(appsPath, 'Arm64Asar.app'), {});
noAsarFiles = await getAllAppFiles(path.resolve(appsPath, 'Arm64NoAsar.app'), {});
});
it('should correctly identify plist files', async () => {
expect(asarFiles.find((f) => f.relativePath === 'Contents/Info.plist')?.type).toBe(
AppFileType.INFO_PLIST,
);
});
it('should correctly identify asar files as app code', async () => {
expect(asarFiles.find((f) => f.relativePath === 'Contents/Resources/app.asar')?.type).toBe(
AppFileType.APP_CODE,
);
});
it('should correctly identify non-asar code files as plain text', async () => {
expect(
noAsarFiles.find((f) => f.relativePath === 'Contents/Resources/app/index.js')?.type,
).toBe(AppFileType.PLAIN);
});
it('should correctly identify the Electron binary as Mach-O', async () => {
expect(noAsarFiles.find((f) => f.relativePath === 'Contents/MacOS/Electron')?.type).toBe(
AppFileType.MACHO,
);
});
it('should correctly identify the Electron Framework as Mach-O', async () => {
expect(
noAsarFiles.find(
(f) =>
f.relativePath ===
'Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework',
)?.type,
).toBe(AppFileType.MACHO);
});
it('should correctly identify the v8 context snapshot', async () => {
expect(
noAsarFiles.find(
(f) =>
f.relativePath ===
'Contents/Frameworks/Electron Framework.framework/Versions/A/Resources/v8_context_snapshot.arm64.bin',
)?.type,
).toBe(AppFileType.SNAPSHOT);
});
});
});