Files
furbo-vpn-edition/dashboard/node_modules/simple-update-notifier/src/getDistVersion.spec.ts
renato97 8fc8991efa Add v9.1.1: Device registry and remote blocking system
- Implement DeviceRegistry for remote device management
- Add dashboard for device tracking and blocking
- Remote device blocking capability with admin control
- Support for device aliasing and notes
- Enhanced device management interface
- Dashboard with real-time device status
- Configurable registry URL in build config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 21:37:11 +01:00

36 lines
810 B
TypeScript

import Stream from 'stream';
import https from 'https';
import getDistVersion from './getDistVersion';
jest.mock('https', () => ({
get: jest.fn(),
}));
test('Valid response returns version', async () => {
const st = new Stream();
(https.get as jest.Mock).mockImplementation((url, cb) => {
cb(st);
st.emit('data', '{"latest":"1.0.0"}');
st.emit('end');
});
const version = await getDistVersion('test', 'latest');
expect(version).toEqual('1.0.0');
});
test('Invalid response throws error', async () => {
const st = new Stream();
(https.get as jest.Mock).mockImplementation((url, cb) => {
cb(st);
st.emit('data', 'some invalid json');
st.emit('end');
});
expect(getDistVersion('test', 'latest')).rejects.toThrow(
'Could not parse version response'
);
});