mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
convert macOS check to utility function
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
|
||||
import { isMacOS } from './os';
|
||||
|
||||
describe('isMacOS', () => {
|
||||
test('is true', () => {
|
||||
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('MacIntel');
|
||||
expect(isMacOS()).toBeTruthy();
|
||||
});
|
||||
test('is false', () => {
|
||||
jest.spyOn(navigator, 'platform', 'get').mockReturnValue('Win32');
|
||||
expect(isMacOS()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2021 The Pybricks Authors
|
||||
|
||||
// Utility functions for dealing with operating systems.
|
||||
|
||||
export function isMacOS(): boolean {
|
||||
return /mac/i.test(navigator.platform);
|
||||
}
|
||||
Reference in New Issue
Block a user