mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
firmware: add windows BLE hacks
This works around some issues that have been observed on a specific Windows computer. Issue: https://github.com/pybricks/support/issues/256
This commit is contained in:
+12
-1
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
|
||||
import { isMacOS, prefersDarkMode } from './os';
|
||||
import { isMacOS, isWindows, prefersDarkMode } from './os';
|
||||
|
||||
describe('isMacOS', () => {
|
||||
test('is true', () => {
|
||||
@@ -14,6 +14,17 @@ describe('isMacOS', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWindows', () => {
|
||||
test('is true', () => {
|
||||
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('Win32');
|
||||
expect(isWindows()).toBeTruthy();
|
||||
});
|
||||
test('is false', () => {
|
||||
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('MacIntel');
|
||||
expect(isWindows()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('prefersDarkMode', () => {
|
||||
test('is true', () => {
|
||||
window.matchMedia = jest.fn().mockReturnValue({
|
||||
|
||||
@@ -11,6 +11,14 @@ export function isMacOS(): boolean {
|
||||
return /mac/i.test(navigator.platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if we are running on Windows.
|
||||
* @returns `true` if running on Windows, otherwise `false`.
|
||||
*/
|
||||
export function isWindows(): boolean {
|
||||
return /win/i.test(navigator.platform);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the OS is set to dark mode.
|
||||
* @returns: `true` if dark mode should be preferred, otherwise `false`.
|
||||
|
||||
Reference in New Issue
Block a user