From: Ardis Lu Date: Wed, 15 Jul 2026 05:26:03 +0000 (-0700) Subject: Add tests for empty env file X-Git-Tag: v0.1.4~12 X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=c26f21dac23da410cd5cbe5b23805b1a258d167c;p=envpass Add tests for empty env file --- diff --git a/test/index.test.js b/test/index.test.js index d8e722b..7840c23 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -58,6 +58,17 @@ suite('e2e', () => { await fileEqual(envFile, env); deepStrictEqual(openMock.mock.calls.length, 0); }); + test('encrypt does nothing when env is empty', async (t) => { + const openMock = t.mock.method(BROWSER, 'open'); + const env = ''; + const envFile = await setupEnv(t, env); + assertConsole(t, { debug: 0, info: 0, warn: 0, error: 0 }); + + await encrypt({ inFile: envFile }); + + await fileEqual(envFile, env); + deepStrictEqual(openMock.mock.calls.length, 0); + }); test('decrypt does nothing when all variables are already decrypted', async (t) => { const openMock = t.mock.method(BROWSER, 'open'); const envFile = await setupEnv(t, STD_ENV); @@ -68,4 +79,15 @@ suite('e2e', () => { await fileEqual(envFile, STD_ENV); deepStrictEqual(openMock.mock.calls.length, 0); }); + test('decrypt does nothing when env is empty', async (t) => { + const openMock = t.mock.method(BROWSER, 'open'); + const env = ''; + const envFile = await setupEnv(t, env); + assertConsole(t, { debug: 0, info: 0, warn: 0, error: 0 }); + + await decrypt({ inFile: envFile }); + + await fileEqual(envFile, env); + deepStrictEqual(openMock.mock.calls.length, 0); + }); });