summaryrefslogtreecommitdiff
path: root/tests/test.browser.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.browser.js')
-rw-r--r--tests/test.browser.js62
1 files changed, 61 insertions, 1 deletions
diff --git a/tests/test.browser.js b/tests/test.browser.js
index f80b12e..4fdc084 100644
--- a/tests/test.browser.js
+++ b/tests/test.browser.js
@@ -1,9 +1,69 @@
/* eslint-disable no-console */
const expect = chai.expect;
-import { isSafari, isFirefox, isChrome, isChromium, isOpera, isEdge,
+import { isMac, isWindows, isIOS,
+ isSafari, isFirefox, isChrome, isChromium, isOpera, isEdge,
isGecko, isWebKit, isBlink } from '../core/util/browser.js';
+describe('OS detection', function () {
+ let origNavigator;
+ beforeEach(function () {
+ // window.navigator is a protected read-only property in many
+ // environments, so we need to redefine it whilst running these
+ // tests.
+ origNavigator = Object.getOwnPropertyDescriptor(window, "navigator");
+
+ Object.defineProperty(window, "navigator", {value: {}});
+ });
+
+ afterEach(function () {
+ Object.defineProperty(window, "navigator", origNavigator);
+ });
+
+ it('should handle macOS', function () {
+ const platforms = [
+ "MacIntel",
+ "MacPPC",
+ ];
+
+ platforms.forEach((platform) => {
+ navigator.platform = platform;
+ expect(isMac()).to.be.true;
+ expect(isWindows()).to.be.false;
+ expect(isIOS()).to.be.false;
+ });
+ });
+
+ it('should handle Windows', function () {
+ const platforms = [
+ "Win32",
+ "Win64",
+ ];
+
+ platforms.forEach((platform) => {
+ navigator.platform = platform;
+ expect(isMac()).to.be.false;
+ expect(isWindows()).to.be.true;
+ expect(isIOS()).to.be.false;
+ });
+ });
+
+ it('should handle iOS', function () {
+ const platforms = [
+ "iPhone",
+ "iPod",
+ "iPad",
+ ];
+
+ platforms.forEach((platform) => {
+ navigator.platform = platform;
+ expect(isMac()).to.be.false;
+ expect(isWindows()).to.be.false;
+ expect(isIOS()).to.be.true;
+ });
+ });
+});
+
describe('Browser detection', function () {
let origNavigator;
beforeEach(function () {