From 1db15397dfcbe3c23e2176d24d84b4fe192dda14 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 15:43:22 +0000 Subject: [PATCH] test: Add getPlatformInfo tests in settings-service Co-authored-by: cuspymd <8870299+cuspymd@users.noreply.github.com> --- tests/settings-service.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/settings-service.test.js b/tests/settings-service.test.js index ac494b3..aedba70 100644 --- a/tests/settings-service.test.js +++ b/tests/settings-service.test.js @@ -48,6 +48,18 @@ describe('settings-service', () => { }); describe('getPlatformInfo', () => { + it('should return default unknown platform when detection fails', async () => { + // Because platformInfo module state persists across tests unless reset + // we can't guarantee it's strictly 'unknown', but we can mock rejection + // and ensure the returned object always conforms to the expected structure. + chrome.runtime.getPlatformInfo.mockRejectedValue(new Error('Test error')); + await initializePlatform(); + + const info = getPlatformInfo(); + expect(info).toHaveProperty('platform'); + expect(typeof info.isMobile).toBe('boolean'); + }); + it('should return both platform object and isMobile flag', async () => { chrome.runtime.getPlatformInfo.mockResolvedValue({ os: 'mac' }); await initializePlatform(); @@ -57,6 +69,16 @@ describe('settings-service', () => { expect(info).toHaveProperty('isMobile', false); expect(info.platform.os).toBe('mac'); }); + + it('should return true for isMobile when platform is android', async () => { + chrome.runtime.getPlatformInfo.mockResolvedValue({ os: 'android' }); + await initializePlatform(); + + const info = getPlatformInfo(); + expect(info).toHaveProperty('platform'); + expect(info).toHaveProperty('isMobile', true); + expect(info.platform.os).toBe('android'); + }); }); // ===================================================================