PHP 8.2.30
Preview: index.spec.ts Size: 744 B
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/simple-update-notifier/src/index.spec.ts

import simpleUpdateNotifier from '.';
import hasNewVersion from './hasNewVersion';

const consoleSpy = jest.spyOn(console, 'error');

jest.mock('./hasNewVersion', () => jest.fn().mockResolvedValue('2.0.0'));

beforeEach(jest.clearAllMocks);

test('it logs message if update is available', async () => {
  await simpleUpdateNotifier({
    pkg: { name: 'test', version: '1.0.0' },
    alwaysRun: true,
  });

  expect(consoleSpy).toHaveBeenCalledTimes(1);
});

test('it does not log message if update is not available', async () => {
  (hasNewVersion as jest.Mock).mockResolvedValue(false);
  await simpleUpdateNotifier({
    pkg: { name: 'test', version: '2.0.0' },
    alwaysRun: true,
  });

  expect(consoleSpy).toHaveBeenCalledTimes(0);
});

Directory Contents

Dirs: 0 × Files: 11

Name Size Perms Modified Actions
371 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
527 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
1.03 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
810 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
811 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
2.32 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
1.12 KB lrw-r--r-- 2026-02-03 15:06:46
Edit Download
744 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
984 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
444 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download
202 B lrw-r--r-- 2026-02-03 15:06:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).