describe('ClientVersionCollector', () => { beforeEach(() => { jest.resetModules(); }); it('should get version from react-native-device-info default export when available', () => { jest.doMock('react-native-device-info', () => ({ default: { getVersion: () => '3.0.0', }, }), { virtual: true }); const { getClientVersion } = require('../hooks/useClientVersionCollector'); expect(getClientVersion()).toBe('3.0.0'); }); it('should get version from react-native-device-info direct export when default is not available', () => { jest.doMock('react-native-device-info', () => ({ getVersion: () => '4.0.0', }), { virtual: true }); const { getClientVersion } = require('../hooks/useClientVersionCollector'); expect(getClientVersion()).toBe('4.0.0'); }); it('should return "unknown" when react-native-device-info is not available', () => { jest.doMock('react-native-device-info', () => { throw new Error('Module not found'); }, { virtual: true }); const { getClientVersion } = require('../hooks/useClientVersionCollector'); expect(getClientVersion()).toBe('unknown'); }); it('should return "unknown" when react-native-device-info has no getVersion method', () => { jest.doMock('react-native-device-info', () => ({ default: {}, }), { virtual: true }); const { getClientVersion } = require('../hooks/useClientVersionCollector'); expect(getClientVersion()).toBe('unknown'); }); it('should prefer default.getVersion when both default and direct getVersion are available', () => { jest.doMock('react-native-device-info', () => ({ default: { getVersion: () => '5.0.0', }, getVersion: () => '6.0.0', }), { virtual: true }); const { getClientVersion } = require('../hooks/useClientVersionCollector'); expect(getClientVersion()).toBe('5.0.0'); }); });