]> git.ardis.lu - envpass/commitdiff
Add tests for empty env file
authorArdis Lu <ardisglu@gmail.com>
Wed, 15 Jul 2026 05:26:03 +0000 (22:26 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 15 Jul 2026 05:26:03 +0000 (22:26 -0700)
test/index.test.js

index d8e722b81b6ca2dcfb0a1a361b900f27a1a62b72..7840c23b8662cb091ba7310b80df5933a84d0326 100644 (file)
@@ -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);
+  });
 });
This page took 0.070017 seconds and 4 git commands to generate.