REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.32 KB
Close
/home/byroehnu/.trash/node_modules11/simple-update-notifier/src/hasNewVersion.spec.ts
Text
Base64
import hasNewVersion from './hasNewVersion'; import { getLastUpdate } from './cache'; import getDistVersion from './getDistVersion'; jest.mock('./getDistVersion', () => jest.fn().mockReturnValue('1.0.0')); jest.mock('./cache', () => ({ getLastUpdate: jest.fn().mockReturnValue(undefined), createConfigDir: jest.fn(), saveLastUpdate: jest.fn(), })); const pkg = { name: 'test', version: '1.0.0' }; afterEach(() => jest.clearAllMocks()); const defaultArgs = { pkg, shouldNotifyInNpmScript: true, alwaysRun: true, }; test('it should not trigger update for same version', async () => { const newVersion = await hasNewVersion(defaultArgs); expect(newVersion).toBe(false); }); test('it should trigger update for patch version bump', async () => { (getDistVersion as jest.Mock).mockReturnValue('1.0.1'); const newVersion = await hasNewVersion(defaultArgs); expect(newVersion).toBe('1.0.1'); }); test('it should trigger update for minor version bump', async () => { (getDistVersion as jest.Mock).mockReturnValue('1.1.0'); const newVersion = await hasNewVersion(defaultArgs); expect(newVersion).toBe('1.1.0'); }); test('it should trigger update for major version bump', async () => { (getDistVersion as jest.Mock).mockReturnValue('2.0.0'); const newVersion = await hasNewVersion(defaultArgs); expect(newVersion).toBe('2.0.0'); }); test('it should not trigger update if version is lower', async () => { (getDistVersion as jest.Mock).mockReturnValue('0.0.9'); const newVersion = await hasNewVersion(defaultArgs); expect(newVersion).toBe(false); }); it('should trigger update check if last update older than config', async () => { const TWO_WEEKS = new Date().getTime() - 1000 * 60 * 60 * 24 * 14; (getLastUpdate as jest.Mock).mockReturnValue(TWO_WEEKS); const newVersion = await hasNewVersion({ pkg, shouldNotifyInNpmScript: true, }); expect(newVersion).toBe(false); expect(getDistVersion).toHaveBeenCalled(); }); it('should not trigger update check if last update is too recent', async () => { const TWELVE_HOURS = new Date().getTime() - 1000 * 60 * 60 * 12; (getLastUpdate as jest.Mock).mockReturnValue(TWELVE_HOURS); const newVersion = await hasNewVersion({ pkg, shouldNotifyInNpmScript: true, }); expect(newVersion).toBe(false); expect(getDistVersion).not.toHaveBeenCalled(); });
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 11
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
borderedText.ts
371 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
cache.spec.ts
527 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
cache.ts
1.03 KB
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
getDistVersion.spec.ts
810 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
getDistVersion.ts
811 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
hasNewVersion.spec.ts
2.32 KB
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
hasNewVersion.ts
1.12 KB
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.spec.ts
744 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
984 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
isNpmOrYarn.ts
444 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
types.ts
202 B
lrw-r--r--
2026-02-03 15:06:46
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).