mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
use os detection for initial dark mode setting
This commit is contained in:
+20
-1
@@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
|
||||
import { isMacOS } from './os';
|
||||
import { isMacOS, prefersDarkMode } from './os';
|
||||
|
||||
describe('isMacOS', () => {
|
||||
test('is true', () => {
|
||||
@@ -13,3 +13,22 @@ describe('isMacOS', () => {
|
||||
expect(isMacOS()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('prefersDarkMode', () => {
|
||||
test('is true', () => {
|
||||
window.matchMedia = jest.fn().mockReturnValue({
|
||||
matches: true,
|
||||
} as MediaQueryList);
|
||||
expect(prefersDarkMode()).toBeTruthy();
|
||||
});
|
||||
test('is false', () => {
|
||||
// @ts-expect-error 2790
|
||||
delete window.matchMedia;
|
||||
expect(prefersDarkMode()).toBeFalsy();
|
||||
|
||||
window.matchMedia = jest.fn().mockReturnValue({
|
||||
matches: false,
|
||||
} as MediaQueryList);
|
||||
expect(prefersDarkMode()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user