You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
744 B

1 month ago
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);
});