This commit is contained in:
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

546
node_modules/ismobilejs/src/__tests__/amazon.test.ts generated vendored Normal file
View File

@@ -0,0 +1,546 @@
import isMobile, { isMobileResult } from '../';
describe('Amazon', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('Amazon Kindle Fire User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFOT Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HD User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFTT Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HD 8.9inch User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFJWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HD 8.9inch 4G User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFJWA Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HD 7inch (3rd Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFSOWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HDX 7inch (3rd Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFTHWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HDX 7 (3rd Generation) 4G User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFTHWA Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HDX 8.9inch (3rd Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFAPWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Kindle Fire HDX 8.9inch (3rd Generation) 4G User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFAPWA Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire HD 6 (4th Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFARWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire HD 7 (4th Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFASWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire HDX 8.9 (4th Generation) User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFSAWI Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire HDX 8.9 (4th Generation) 4G User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; KFSAWA Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should not be an Amazon Phone', () => {
expect(mobile.amazon.phone).not.toBe(true);
});
test('should be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire Phone User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; U; Android android-version; locale; SD4930UR Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should be an Amazon Phone', () => {
expect(mobile.amazon.phone).toBe(true);
});
test('should not be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).not.toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should be an Android Phone', () => {
expect(mobile.android.phone).toBe(true);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Amazon Fire Generic Phone User Agent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; Android android-version; product-model Build/product-build) AppleWebKit/webkit-version (KHTML, like Gecko) Silk/browser-version like Chrome/chrome-version Mobile Safari/webkit-version';
mobile = isMobile(userAgent);
});
test('should be an Amazon Phone', () => {
expect(mobile.amazon.phone).toBe(true);
});
test('should not be an Amazon Tablet', () => {
expect(mobile.amazon.tablet).not.toBe(true);
});
test('should be an Amazon device', () => {
expect(mobile.amazon.device).toBe(true);
});
test('should be an Android Phone', () => {
expect(mobile.android.phone).toBe(true);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
});

77
node_modules/ismobilejs/src/__tests__/android.test.ts generated vendored Normal file
View File

@@ -0,0 +1,77 @@
import isMobile, { isMobileResult } from '../';
describe('Android', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('Phone UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>';
mobile = isMobile(userAgent);
});
test('should be an Android Phone', () => {
expect(mobile.android.phone).toBe(true);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Tablet UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev>(KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev>';
mobile = isMobile(userAgent);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('OkHttp UserAgent', () => {
beforeEach(() => {
userAgent = 'okhttp/3.9.1';
mobile = isMobile(userAgent);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).toBe(false);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(false);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(false);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
});

214
node_modules/ismobilejs/src/__tests__/apple.test.ts generated vendored Normal file
View File

@@ -0,0 +1,214 @@
import isMobile, { isMobileResult } from '../';
describe('Apple', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('iPhone UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3';
mobile = isMobile(userAgent);
});
test('should be an iPhone', () => {
expect(mobile.apple.phone).toBe(true);
});
test('should not be an iPad', () => {
expect(mobile.apple.tablet).not.toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('iPad UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10';
mobile = isMobile(userAgent);
});
test('should not be an iPhone', () => {
expect(mobile.apple.phone).not.toBe(true);
});
test('should be an iPad', () => {
expect(mobile.apple.tablet).toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('iPad on iOS 13', () => {
beforeEach(() => {
const nav = {
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko)',
platform: 'MacIntel',
maxTouchPoints: 4,
};
mobile = isMobile(nav);
});
test('should not be an iPhone', () => {
expect(mobile.apple.phone).not.toBe(true);
});
test('should be an iPad', () => {
expect(mobile.apple.tablet).toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('iPod UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3';
mobile = isMobile(userAgent);
});
test('should not be an iPhone', () => {
expect(mobile.apple.phone).not.toBe(true);
});
test('should not be an iPad', () => {
expect(mobile.apple.tablet).not.toBe(true);
});
test('should be an iPod', () => {
expect(mobile.apple.ipod).toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('Facebook iPhone App UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPhone; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B410 [FBAN/FBIOS;FBAV/20.1.0.15.10;FBBV/5758778;FBDV/iPad5,4;FBMD/iPad;FBSN/iPhone OS;FBSV/8.1;FBSS/2; FBCR/;FBID/tablet;FBLC/fi_FI;FBOP/1]';
mobile = isMobile(userAgent);
});
test('should be an iPhone', () => {
expect(mobile.apple.phone).toBe(true);
});
test('should not be an iPad', () => {
expect(mobile.apple.tablet).not.toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('Facebook iPad App UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPad; CPU OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B410 [FBAN/FBIOS;FBAV/20.1.0.15.10;FBBV/5758778;FBDV/iPad5,4;FBMD/iPad;FBSN/iPhone OS;FBSV/8.1;FBSS/2; FBCR/;FBID/tablet;FBLC/fi_FI;FBOP/1]';
mobile = isMobile(userAgent);
});
test('should not be an iPhone', () => {
expect(mobile.apple.phone).not.toBe(true);
});
test('should be an iPad', () => {
expect(mobile.apple.tablet).toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('Twitter iPhone App UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13D15 Twitter for iPhone';
mobile = isMobile(userAgent);
});
test('should be an iPhone', () => {
expect(mobile.apple.phone).toBe(true);
});
test('should not be an iPad', () => {
expect(mobile.apple.tablet).not.toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
describe('Twitter iPad App UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (iPad; CPU OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13D15 Twitter for iPhone';
mobile = isMobile(userAgent);
});
test('should not be an iPhone', () => {
expect(mobile.apple.phone).not.toBe(true);
});
test('should be an iPad', () => {
expect(mobile.apple.tablet).toBe(true);
});
test('should not be an iPod', () => {
expect(mobile.apple.ipod).not.toBe(true);
});
test('should be an Apple device', () => {
expect(mobile.apple.device).toBe(true);
});
});
});

View File

@@ -0,0 +1,179 @@
import puppeteer from 'puppeteer';
import { isMobileResult } from '..';
describe('E2E Tests', () => {
test('isMobile global variable is present', async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setUserAgent('okhttp/3.0.0');
await page.addScriptTag({ path: './dist/isMobile.min.js' });
const isMobile: isMobileResult = await page.evaluate(() => isMobile);
expect(isMobile).toMatchInlineSnapshot(`
Object {
"amazon": Object {
"device": false,
"phone": false,
"tablet": false,
},
"android": Object {
"device": true,
"phone": false,
"tablet": false,
},
"any": true,
"apple": Object {
"device": false,
"ipod": false,
"phone": false,
"tablet": false,
"universal": false,
},
"other": Object {
"blackberry": false,
"blackberry10": false,
"chrome": false,
"device": false,
"firefox": false,
"opera": false,
},
"phone": false,
"tablet": false,
"windows": Object {
"device": false,
"phone": false,
"tablet": false,
},
}
`);
await browser.close();
});
(process.env.GITHUB_ACTIONS ? test.skip : test)(
'isMobile correctly checks iOS 13',
async () => {
const iPadIos13 = {
...puppeteer.devices['iPad Pro'],
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko)',
};
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'maxTouchPoints', {
get: () => 4,
});
});
await page.emulate(iPadIos13);
await page.addScriptTag({ path: './dist/isMobile.min.js' });
const isMobile: isMobileResult = await page.evaluate(() => isMobile);
// eslint-disable-next-line jest/no-standalone-expect
expect(isMobile).toMatchInlineSnapshot(`
Object {
"amazon": Object {
"device": false,
"phone": false,
"tablet": false,
},
"android": Object {
"device": false,
"phone": false,
"tablet": false,
},
"any": true,
"apple": Object {
"device": true,
"ipod": false,
"phone": false,
"tablet": true,
"universal": false,
},
"other": Object {
"blackberry": false,
"blackberry10": false,
"chrome": false,
"device": false,
"firefox": false,
"opera": false,
},
"phone": false,
"tablet": true,
"windows": Object {
"device": false,
"phone": false,
"tablet": false,
},
}
`);
await browser.close();
},
);
test('isMobile correctly fails iOS 13 check when MSStream is present', async () => {
const iPadIos13 = {
...puppeteer.devices['iPad Pro'],
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko)',
};
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, 'maxTouchPoints', {
get: () => 4,
});
Object.defineProperty(window, 'MSStream', {
get: () => (fn: Function) => fn(),
});
});
await page.emulate(iPadIos13);
await page.addScriptTag({ path: './dist/isMobile.min.js' });
const isMobile: isMobileResult = await page.evaluate(() => isMobile);
expect(isMobile).toMatchInlineSnapshot(`
Object {
"amazon": Object {
"device": false,
"phone": false,
"tablet": false,
},
"android": Object {
"device": false,
"phone": false,
"tablet": false,
},
"any": false,
"apple": Object {
"device": false,
"ipod": false,
"phone": false,
"tablet": false,
"universal": false,
},
"other": Object {
"blackberry": false,
"blackberry10": false,
"chrome": false,
"device": false,
"firefox": false,
"opera": false,
},
"phone": false,
"tablet": false,
"windows": Object {
"device": false,
"phone": false,
"tablet": false,
},
}
`);
await browser.close();
});
});

30
node_modules/ismobilejs/src/__tests__/desktop.test.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import isMobile, { isMobileResult } from '../';
describe('Desktop', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('Chrome', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19';
mobile = isMobile(userAgent);
});
test('should not be a mobile device', () => {
expect(mobile.any).not.toBe(true);
});
});
describe('Safari', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.53.11 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10';
mobile = isMobile(userAgent);
});
test('should not be a mobile device', () => {
expect(mobile.any).not.toBe(true);
});
});
});

153
node_modules/ismobilejs/src/__tests__/other.test.ts generated vendored Normal file
View File

@@ -0,0 +1,153 @@
import isMobile, { isMobileResult } from '../';
describe('Other Mobile Devices', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('BlackBerry 10', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.35+ (KHTML, like Gecko) Version/10.2.0.1791 Mobile Safari/537.35+';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a BlackBerry 10 device', () => {
expect(mobile.other.blackberry10).toBe(true);
});
test('should not be a BlackBerry device', () => {
expect(mobile.other.blackberry).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('BlackBerry', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a BlackBerry device', () => {
expect(mobile.other.blackberry).toBe(true);
});
test('should not be a BlackBerry 10 device', () => {
expect(mobile.other.blackberry10).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Opera Mini', () => {
beforeEach(() => {
userAgent =
'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be an Opera Mini device', () => {
expect(mobile.other.opera).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Firefox OS', () => {
beforeEach(() => {
userAgent = 'Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a Firefox OS device', () => {
expect(mobile.other.firefox).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Chrome', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; Android 4.4.4; en-us; Nexus 4 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2307.2 Mobile Safari/537.36';
mobile = isMobile(userAgent);
});
test('should be a Chrome device', () => {
expect(mobile.other.chrome).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
test('should not be a Firefox OS device', () => {
expect(mobile.other.firefox).toBe(false);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
});

154
node_modules/ismobilejs/src/__tests__/windows.test.ts generated vendored Normal file
View File

@@ -0,0 +1,154 @@
import isMobile, { isMobileResult } from '../';
describe('Windows', () => {
let mobile: isMobileResult;
let userAgent: string;
describe('Windows Phone UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)';
mobile = isMobile(userAgent);
});
test('should be a Windows Phone device', () => {
expect(mobile.windows.phone).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Windows 8.1 Phone UserAgent', () => {
beforeEach(() => {
userAgent =
'//Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537';
mobile = isMobile(userAgent);
});
test('should be a Windows Phone device', () => {
expect(mobile.windows.phone).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Windows Edge Phone UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; <Manufacturer>; <Device>) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166';
mobile = isMobile(userAgent);
});
test('should be a Windows Phone device', () => {
expect(mobile.windows.phone).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Windows Tablet UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)';
mobile = isMobile(userAgent);
});
test('should be a Windows Tablet device', () => {
expect(mobile.windows.tablet).toBe(true);
});
test('should not be a Windows Phone device', () => {
expect(mobile.windows.phone).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Windows Touch Laptop UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; MAGWJS; rv:11.0) like Gecko';
mobile = isMobile(userAgent);
});
test('should not be a Windows Tablet device', () => {
expect(mobile.windows.tablet).not.toBe(true);
});
test('should not be a Windows Phone device', () => {
expect(mobile.windows.phone).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should not be matched as Any Tablet', () => {
expect(mobile.tablet).not.toBe(true);
});
test('should not be a mobile device', () => {
expect(mobile.any).not.toBe(true);
});
});
});