From a4354f09edcb95a95a2b0e52fcd331df992083d1 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Wed, 12 Jun 2024 22:32:11 -0700 Subject: [PATCH] test: improve coverage --- test/index.spec.ts | 64 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/test/index.spec.ts b/test/index.spec.ts index 418861e..815dcac 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -15,26 +15,56 @@ async function ensureUniversal(app: string) { } describe('makeUniversalApp', () => { - it('should correctly merge two identical asars', async () => { - const out = path.resolve(appsPath, 'MergedAsar.app'); - await makeUniversalApp({ - x64AppPath: path.resolve(appsPath, 'X64Asar.app'), - arm64AppPath: path.resolve(appsPath, 'Asar.app'), - outAppPath: out, + it.todo('`force` works'); + it.todo('works for lipo binary resources'); + + describe('asar mode', () => { + it('should correctly merge two identical asars', async () => { + const out = path.resolve(appsPath, 'MergedAsar.app'); + await makeUniversalApp({ + x64AppPath: path.resolve(appsPath, 'X64Asar.app'), + arm64AppPath: path.resolve(appsPath, 'Asar.app'), + outAppPath: out, + }); + await ensureUniversal(out); + // Only a single asar as they were identical + expect( + (await fs.readdir(path.resolve(out, 'Contents', 'Resources'))).filter((p) => + p.endsWith('asar'), + ), + ).toEqual(['app.asar']); + }, 60000); + it('should create two separate non-identical ASAR files', async () => { + const out = path.resolve(appsPath, 'TwoAsars.app'); + await makeUniversalApp({ + x64AppPath: path.resolve(appsPath, 'X64Asar.app'), + arm64AppPath: path.resolve(appsPath, 'Asar.app'), + outAppPath: out, + }); + await ensureUniversal(out); }); - await ensureUniversal(out); - // Only a single asar as they were identical - expect( - (await fs.readdir(path.resolve(out, 'Contents', 'Resources'))).filter((p) => - p.endsWith('asar'), - ), - ).toEqual(['app.asar']); - }, 60000); + it.todo('should correctly merge two non-identical asars when `mergeASARs` is enabled'); + it.todo('should not inject ElectronAsarIntegrity into `infoPlistsToIgnore`'); + }); + + describe('no asar mode', () => { + it('should correctly merge two identical app folders', async () => { + const out = path.resolve(appsPath, 'MergedNoAsar.app'); + await makeUniversalApp({ + x64AppPath: path.resolve(appsPath, 'X64NoAsar.app'), + arm64AppPath: path.resolve(appsPath, 'NoAsar.app'), + outAppPath: out, + }); + await ensureUniversal(out); + // Only a single app folder as they were identical + expect( + (await fs.readdir(path.resolve(out, 'Contents', 'Resources'))).filter((p) => p === 'app'), + ).toEqual(['app']); + }, 60000); + it.todo('should create two separate non-identical app folders'); + }); // TODO: Add tests for - // * different asar files - // * identical app dirs - // * different app dirs // * different app dirs with different macho files // * identical app dirs with universal macho files });