]> git.ardis.lu - envpass/commitdiff
Add logger test variants
authorArdis Lu <ardisglu@gmail.com>
Sun, 16 Aug 2026 07:07:56 +0000 (00:07 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 16 Aug 2026 07:07:56 +0000 (00:07 -0700)
test/index.test.js

index 3a6b066ed62baea37ab29bd0b1edd9362b08545b..04d143c88c24b774b310156fae13b3c6e2c074b9 100644 (file)
@@ -65,6 +65,16 @@ suite('encrypt', () => {
     await encrypt({ inFile: envFile });
     await fileEqual(envFile, '');
   });
+  test('does nothing to empty .env file (with logs)', async (t) => {
+    const { page } = await setupPlaywright(t);
+    const envFile = await setupEnv(t, '');
+    mockOpen(t, page);
+    assertConsole(t, { debug: 1, info: 1, warn: 0, error: 0 });
+
+    await fileEqual(envFile, '');
+    await encrypt({ inFile: envFile, logger: console });
+    await fileEqual(envFile, '');
+  });
   test('does nothing when all variables are already encrypted', async (t) => {
     const openMock = t.mock.method(BROWSER, 'open');
     const env = 'A=envpass:v1:AAA\nB=envpass:v1:BBB\nC=envpass:v1:CCC\n';
@@ -119,6 +129,16 @@ suite('decrypt', () => {
     await decrypt({ inFile: envFile });
     await fileEqual(envFile, '');
   });
+  test('does nothing to empty .env file (with logs)', async (t) => {
+    const { page } = await setupPlaywright(t);
+    const envFile = await setupEnv(t, '');
+    mockOpen(t, page);
+    assertConsole(t, { debug: 1, info: 1, warn: 0, error: 0 });
+
+    await fileEqual(envFile, '');
+    await decrypt({ inFile: envFile, logger: console });
+    await fileEqual(envFile, '');
+  });
   test('does nothing when all variables are already decrypted', async (t) => {
     const openMock = t.mock.method(BROWSER, 'open');
     const envFile = await setupEnv(t, STD_ENV);
@@ -151,8 +171,17 @@ suite('decrypt', () => {
   test('passes through excess args to execute', async (t) => {
     const execMock = t.mock.method(childProcess, 'execSync', () => { });
     const envFile = await setupEnv(t, STD_ENV);
+    assertConsole(t, { debug: 0, info: 0, warn: 0, error: 0 });
 
     await decrypt({ inFile: envFile }, { args: ['test', 'test', 'test'] });
     deepStrictEqual(execMock.mock.calls.length, 1);
   });
+  test('passes through excess args to execute (with logs)', async (t) => {
+    const execMock = t.mock.method(childProcess, 'execSync', () => { });
+    const envFile = await setupEnv(t, STD_ENV);
+    assertConsole(t, { debug: 4, info: 0, warn: 0, error: 0 });
+
+    await decrypt({ inFile: envFile, logger: console }, { args: ['test', 'test', 'test'] });
+    deepStrictEqual(execMock.mock.calls.length, 1);
+  });
 });
This page took 0.041358 seconds and 4 git commands to generate.