-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for macOS15 chrome workaround
- Loading branch information
Showing
2 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ServiceWorker } from '../../../src/sw/serviceWorker/ServiceWorker'; | ||
|
||
// suppress all internal logging | ||
jest.mock('../../../src/shared/libraries/Log'); | ||
|
||
function chromeUserAgentDataBrands(): Array<{ | ||
brand: string; | ||
version: string; | ||
}> { | ||
return [ | ||
{ brand: 'Google Chrome', version: '129' }, | ||
{ brand: 'Not=A?Brand', version: '8' }, | ||
{ brand: 'Chromium', version: '129' }, | ||
]; | ||
} | ||
|
||
describe('ServiceWorker', () => { | ||
describe('requiresMacOS15ChromiumAfterDisplayWorkaround', () => { | ||
test('navigator.userAgentData undefined', async () => { | ||
delete (navigator as any).userAgentData; | ||
expect( | ||
ServiceWorker.requiresMacOS15ChromiumAfterDisplayWorkaround(), | ||
).toBe(false); | ||
}); | ||
test('navigator.userAgentData null', async () => { | ||
(navigator as any).userAgentData = null; | ||
expect( | ||
ServiceWorker.requiresMacOS15ChromiumAfterDisplayWorkaround(), | ||
).toBe(false); | ||
}); | ||
|
||
test('navigator.userAgentData Chrome on Windows Desktop', async () => { | ||
(navigator as any).userAgentData = { | ||
mobile: false, | ||
platform: 'Windows', | ||
brands: chromeUserAgentDataBrands(), | ||
}; | ||
expect( | ||
ServiceWorker.requiresMacOS15ChromiumAfterDisplayWorkaround(), | ||
).toBe(false); | ||
}); | ||
test('navigator.userAgentData Chrome on macOS', async () => { | ||
(navigator as any).userAgentData = { | ||
mobile: false, | ||
platform: 'macOS', | ||
brands: chromeUserAgentDataBrands(), | ||
}; | ||
expect( | ||
ServiceWorker.requiresMacOS15ChromiumAfterDisplayWorkaround(), | ||
).toBe(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters