Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 3.148.235.247
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : 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);
});
© 2025 GrazzMean-Shell