mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
[test] Utilize enum in test cases
This commit is contained in:
parent
31bf36c36d
commit
a4342b01d4
@ -8,11 +8,12 @@
|
|||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
|
|
||||||
const { UAParser } = require('../main/ua-parser');
|
const { UAParser } = require('../main/ua-parser');
|
||||||
const { CPUArch, OSName, EngineName, Extension } = require('../enums/ua-parser-enums');
|
const { CPUArch, OSName, EngineName, Extension, BrowserType } = require('../enums/ua-parser-enums');
|
||||||
const { Bots } = require('../extensions/ua-parser-extensions');
|
const { Bots, Crawlers } = require('../extensions/ua-parser-extensions');
|
||||||
const { isFromEU } = require('detect-europe-js');
|
const { isFromEU } = require('detect-europe-js');
|
||||||
const { isFrozenUA } = require('ua-is-frozen');
|
const { isFrozenUA } = require('ua-is-frozen');
|
||||||
const { isStandalonePWA } = require('is-standalone-pwa');
|
const { isStandalonePWA } = require('is-standalone-pwa');
|
||||||
|
const { Crawler } = Extension.BrowserName;
|
||||||
|
|
||||||
const toResult = (value, head, ext) => typeof value === 'string' ? UAParser(value, head, ext) : value;
|
const toResult = (value, head, ext) => typeof value === 'string' ? UAParser(value, head, ext) : value;
|
||||||
|
|
||||||
@ -41,7 +42,6 @@ const isAppleSilicon = (resultOrUA) => {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Crawler = Extension.BrowserName.Crawlers;
|
|
||||||
const isAIBot = (resultOrUA) => [
|
const isAIBot = (resultOrUA) => [
|
||||||
|
|
||||||
// AI2
|
// AI2
|
||||||
@ -158,13 +158,13 @@ const isAIBot = (resultOrUA) => [
|
|||||||
Crawler.ZHIPU_CHATGLM_SPIDER
|
Crawler.ZHIPU_CHATGLM_SPIDER
|
||||||
]
|
]
|
||||||
.map((s) => s.toLowerCase())
|
.map((s) => s.toLowerCase())
|
||||||
.includes(String(toResult(resultOrUA, Bots).browser.name).toLowerCase());
|
.includes(String(toResult(resultOrUA, Crawlers).browser.name).toLowerCase());
|
||||||
|
|
||||||
const isBot = (resultOrUA) => [
|
const isBot = (resultOrUA) => [
|
||||||
'cli',
|
BrowserType.CLI,
|
||||||
'crawler',
|
BrowserType.CRAWLER,
|
||||||
'fetcher',
|
BrowserType.FETCHER,
|
||||||
'library'
|
BrowserType.LIBRARY
|
||||||
].includes(toResult(resultOrUA, Bots).browser.type);
|
].includes(toResult(resultOrUA, Bots).browser.type);
|
||||||
|
|
||||||
const isChromeFamily = (resultOrUA) => toResult(resultOrUA).engine.is(EngineName.BLINK);
|
const isChromeFamily = (resultOrUA) => toResult(resultOrUA).engine.is(EngineName.BLINK);
|
||||||
|
@ -5,6 +5,8 @@ const traverse = require('@babel/traverse').default;
|
|||||||
const safe = require('safe-regex');
|
const safe = require('safe-regex');
|
||||||
const { UAParser } = require('../../src/main/ua-parser');
|
const { UAParser } = require('../../src/main/ua-parser');
|
||||||
const { Bots, CLIs, Crawlers, Emails, Fetchers, InApps, Libraries, Vehicles } = require('../../src/extensions/ua-parser-extensions');
|
const { Bots, CLIs, Crawlers, Emails, Fetchers, InApps, Libraries, Vehicles } = require('../../src/extensions/ua-parser-extensions');
|
||||||
|
const { BrowserType, OSName, Extension } = require('../../src/enums/ua-parser-enums');
|
||||||
|
const { CLI, Crawler, Email, Fetcher, Library } = Extension.BrowserName;
|
||||||
|
|
||||||
describe('Extensions', () => {
|
describe('Extensions', () => {
|
||||||
[
|
[
|
||||||
@ -42,29 +44,29 @@ describe('Extensions', () => {
|
|||||||
const jsdom = 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.3';
|
const jsdom = 'Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/20.0.3';
|
||||||
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
||||||
|
|
||||||
assert.equal(UAParser(scrapy, Bots).browser.name, 'Scrapy');
|
assert.equal(UAParser(scrapy, Bots).browser.name, Library.SCRAPY);
|
||||||
|
|
||||||
const emailParser = new UAParser(Emails);
|
const emailParser = new UAParser(Emails);
|
||||||
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: Email.MICROSOFT_OUTLOOK, version: "16.0.9126", major: "16", type: BrowserType.EMAIL});
|
||||||
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: Email.THUNDERBIRD, version: "78.13.0", major: "78", type: BrowserType.EMAIL});
|
||||||
|
|
||||||
const libraryParser = new UAParser(Libraries);
|
const libraryParser = new UAParser(Libraries);
|
||||||
assert.deepEqual(libraryParser.setUA(axios).getBrowser(), {name: "axios", version: "1.3.5", major: "1", type: "library"});
|
assert.deepEqual(libraryParser.setUA(axios).getBrowser(), {name: Library.AXIOS, version: "1.3.5", major: "1", type: BrowserType.LIBRARY});
|
||||||
assert.deepEqual(libraryParser.setUA(jsdom).getBrowser(), {name: "jsdom", version: "20.0.3", major: "20", type: "library"});
|
assert.deepEqual(libraryParser.setUA(jsdom).getBrowser(), {name: Library.JSDOM, version: "20.0.3", major: "20", type: BrowserType.LIBRARY});
|
||||||
assert.deepEqual(libraryParser.setUA(scrapy).getBrowser(), {name: "Scrapy", version: "1.5.0", major: "1", type: "library"});
|
assert.deepEqual(libraryParser.setUA(scrapy).getBrowser(), {name: Library.SCRAPY, version: "1.5.0", major: "1", type: BrowserType.LIBRARY});
|
||||||
|
|
||||||
// Bluesky
|
// Bluesky
|
||||||
const bluesky = 'Mozilla/5.0 (compatible; Bluesky Cardyb/1.1; +mailto:support@bsky.app)';
|
const bluesky = 'Mozilla/5.0 (compatible; Bluesky Cardyb/1.1; +mailto:support@bsky.app)';
|
||||||
assert.deepEqual(new UAParser(bluesky, Bots).getBrowser(), {
|
assert.deepEqual(new UAParser(bluesky, Bots).getBrowser(), {
|
||||||
name: 'Bluesky',
|
name: Fetcher.BLUESKY,
|
||||||
version: '1.1',
|
version: '1.1',
|
||||||
major: '1',
|
major: '1',
|
||||||
type: 'fetcher'
|
type: BrowserType.FETCHER
|
||||||
});
|
});
|
||||||
|
|
||||||
const whatsapp = "WhatsApp/2.0 A";
|
const whatsapp = "WhatsApp/2.0 A";
|
||||||
assert.deepEqual(new UAParser(whatsapp, Fetchers).getOS(), {
|
assert.deepEqual(new UAParser(whatsapp, Fetchers).getOS(), {
|
||||||
name : 'Android',
|
name : OSName.ANDROID,
|
||||||
version : undefined
|
version : undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -77,14 +79,14 @@ describe('Merge', () => {
|
|||||||
// try merging crawlers & CLIs
|
// try merging crawlers & CLIs
|
||||||
const crawlersAndCLIs = { browser : [...Crawlers.browser, ...CLIs.browser]};
|
const crawlersAndCLIs = { browser : [...Crawlers.browser, ...CLIs.browser]};
|
||||||
const crawlersAndCLIsParser = new UAParser(crawlersAndCLIs);
|
const crawlersAndCLIsParser = new UAParser(crawlersAndCLIs);
|
||||||
assert.deepEqual(crawlersAndCLIsParser.setUA(wget).getBrowser(), {name: "Wget", version: "1.21.1", major: "1", type:"cli"});
|
assert.deepEqual(crawlersAndCLIsParser.setUA(wget).getBrowser(), {name: CLI.WGET, version: "1.21.1", major: "1", type: BrowserType.CLI});
|
||||||
assert.deepEqual(crawlersAndCLIsParser.setUA(facebookBot).getBrowser(), {name: "FacebookBot", version: "1.0", major: "1", type:"crawler"});
|
assert.deepEqual(crawlersAndCLIsParser.setUA(facebookBot).getBrowser(), {name: Crawler.META_FACEBOOKBOT, version: "1.0", major: "1", type: BrowserType.CRAWLER});
|
||||||
|
|
||||||
// alternative merge options
|
// alternative merge options
|
||||||
const crawlersAndCLIsParser2 = new UAParser([Crawlers, CLIs]);
|
const crawlersAndCLIsParser2 = new UAParser([Crawlers, CLIs]);
|
||||||
const crawlersAndCLIsParser3 = new UAParser(facebookBot, [Crawlers, CLIs]);
|
const crawlersAndCLIsParser3 = new UAParser(facebookBot, [Crawlers, CLIs]);
|
||||||
assert.deepEqual(crawlersAndCLIsParser2.setUA(wget).getBrowser(), {name: "Wget", version: "1.21.1", major: "1", type:"cli"});
|
assert.deepEqual(crawlersAndCLIsParser2.setUA(wget).getBrowser(), {name: CLI.WGET, version: "1.21.1", major: "1", type: BrowserType.CLI});
|
||||||
assert.deepEqual(crawlersAndCLIsParser3.getBrowser(), {name: "FacebookBot", version: "1.0", major: "1", type:"crawler"});
|
assert.deepEqual(crawlersAndCLIsParser3.getBrowser(), {name: Crawler.META_FACEBOOKBOT, version: "1.0", major: "1", type: BrowserType.CRAWLER});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ const assert = require('assert');
|
|||||||
const { UAParser } = require('../../src/main/ua-parser');
|
const { UAParser } = require('../../src/main/ua-parser');
|
||||||
const { getDeviceVendor, isAppleSilicon, isAIBot, isBot, isChromeFamily } = require('../../src/helpers/ua-parser-helpers');
|
const { getDeviceVendor, isAppleSilicon, isAIBot, isBot, isChromeFamily } = require('../../src/helpers/ua-parser-helpers');
|
||||||
const { Bots, Emails } = require('../../src/extensions/ua-parser-extensions');
|
const { Bots, Emails } = require('../../src/extensions/ua-parser-extensions');
|
||||||
|
const { DeviceVendor } = require('../../src/enums/ua-parser-enums');
|
||||||
|
|
||||||
describe('getDeviceVendor', () => {
|
describe('getDeviceVendor', () => {
|
||||||
it('Can guess the device vendor from a model name', () => {
|
it('Can guess the device vendor from a model name', () => {
|
||||||
@ -11,10 +12,10 @@ describe('getDeviceVendor', () => {
|
|||||||
const modelNexus = 'Nexus 6P';
|
const modelNexus = 'Nexus 6P';
|
||||||
const modelAquos = 'AQUOS-TVX19B';
|
const modelAquos = 'AQUOS-TVX19B';
|
||||||
|
|
||||||
assert.equal(getDeviceVendor(modelSM), 'Samsung');
|
assert.equal(getDeviceVendor(modelSM), DeviceVendor.SAMSUNG);
|
||||||
assert.equal(getDeviceVendor(modelRedmi), 'Xiaomi');
|
assert.equal(getDeviceVendor(modelRedmi), DeviceVendor.XIAOMI);
|
||||||
assert.equal(getDeviceVendor(modelNexus), 'Huawei');
|
assert.equal(getDeviceVendor(modelNexus), DeviceVendor.HUAWEI);
|
||||||
assert.equal(getDeviceVendor(modelAquos), 'Sharp');
|
assert.equal(getDeviceVendor(modelAquos), DeviceVendor.SHARP);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { UAParser } = require('../../src/main/ua-parser');
|
const { UAParser } = require('../../src/main/ua-parser');
|
||||||
|
const { BrowserName, CPUArch, DeviceType, DeviceVendor, EngineName, OSName } = require('../../src/enums/ua-parser-enums');
|
||||||
const UACHTests = require('../data/ua-ch/headers');
|
const UACHTests = require('../data/ua-ch/headers');
|
||||||
|
|
||||||
describe('Map UA-CH headers', () => {
|
describe('Map UA-CH headers', () => {
|
||||||
@ -26,27 +27,27 @@ describe('Map UA-CH headers', () => {
|
|||||||
it('Can read from client-hints headers using `withClientHints()`', () => {
|
it('Can read from client-hints headers using `withClientHints()`', () => {
|
||||||
|
|
||||||
assert.strictEqual(uap.ua, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
assert.strictEqual(uap.ua, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "93.0.1.2");
|
assert.strictEqual(uap.browser.version, "93.0.1.2");
|
||||||
assert.strictEqual(uap.browser.major, "93");
|
assert.strictEqual(uap.browser.major, "93");
|
||||||
assert.strictEqual(browser.name, "Chrome");
|
assert.strictEqual(browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(browser.version, "93.0.1.2");
|
assert.strictEqual(browser.version, "93.0.1.2");
|
||||||
assert.strictEqual(browser.major, "93");
|
assert.strictEqual(browser.major, "93");
|
||||||
assert.strictEqual(uap.cpu.architecture, "arm64");
|
assert.strictEqual(uap.cpu.architecture, CPUArch.ARM_64);
|
||||||
assert.strictEqual(cpu.architecture, "arm64");
|
assert.strictEqual(cpu.architecture, CPUArch.ARM_64);
|
||||||
assert.strictEqual(uap.device.type, "mobile");
|
assert.strictEqual(uap.device.type, DeviceType.MOBILE);
|
||||||
assert.strictEqual(uap.device.model, "Pixel 99");
|
assert.strictEqual(uap.device.model, "Pixel 99");
|
||||||
assert.strictEqual(uap.device.vendor, "Google");
|
assert.strictEqual(uap.device.vendor, DeviceVendor.GOOGLE);
|
||||||
assert.strictEqual(device.type, "mobile");
|
assert.strictEqual(device.type, DeviceType.MOBILE);
|
||||||
assert.strictEqual(device.model, "Pixel 99");
|
assert.strictEqual(device.model, "Pixel 99");
|
||||||
assert.strictEqual(device.vendor, "Google");
|
assert.strictEqual(device.vendor, DeviceVendor.GOOGLE);
|
||||||
assert.strictEqual(uap.engine.name, 'Blink');
|
assert.strictEqual(uap.engine.name, EngineName.BLINK);
|
||||||
assert.strictEqual(uap.engine.version, '93.0.1.2');
|
assert.strictEqual(uap.engine.version, '93.0.1.2');
|
||||||
assert.strictEqual(engine.name, 'Blink');
|
assert.strictEqual(engine.name, EngineName.BLINK);
|
||||||
assert.strictEqual(engine.version, '93.0.1.2');
|
assert.strictEqual(engine.version, '93.0.1.2');
|
||||||
assert.strictEqual(uap.os.name, "Windows");
|
assert.strictEqual(uap.os.name, OSName.WINDOWS);
|
||||||
assert.strictEqual(uap.os.version, "11");
|
assert.strictEqual(uap.os.version, "11");
|
||||||
assert.strictEqual(os.name, "Windows");
|
assert.strictEqual(os.name, OSName.WINDOWS);
|
||||||
assert.strictEqual(os.version, "11");
|
assert.strictEqual(os.version, "11");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,16 +60,16 @@ describe('Map UA-CH headers', () => {
|
|||||||
engine = new UAParser(headers).getEngine();
|
engine = new UAParser(headers).getEngine();
|
||||||
os = new UAParser(headers).getOS();
|
os = new UAParser(headers).getOS();
|
||||||
|
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "110.0.0.0");
|
assert.strictEqual(uap.browser.version, "110.0.0.0");
|
||||||
assert.strictEqual(uap.browser.major, "110");
|
assert.strictEqual(uap.browser.major, "110");
|
||||||
assert.strictEqual(uap.cpu.architecture, "amd64");
|
assert.strictEqual(uap.cpu.architecture, CPUArch.X86_64);
|
||||||
assert.strictEqual(uap.device.type, undefined);
|
assert.strictEqual(uap.device.type, undefined);
|
||||||
assert.strictEqual(uap.device.model, undefined);
|
assert.strictEqual(uap.device.model, undefined);
|
||||||
assert.strictEqual(uap.device.vendor, undefined);
|
assert.strictEqual(uap.device.vendor, undefined);
|
||||||
assert.strictEqual(uap.engine.name, 'Blink');
|
assert.strictEqual(uap.engine.name, EngineName.BLINK);
|
||||||
assert.strictEqual(uap.engine.version, '110.0.0.0');
|
assert.strictEqual(uap.engine.version, '110.0.0.0');
|
||||||
assert.strictEqual(uap.os.name, "Linux");
|
assert.strictEqual(uap.os.name, OSName.LINUX);
|
||||||
assert.strictEqual(uap.os.version, undefined);
|
assert.strictEqual(uap.os.version, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -81,16 +82,16 @@ describe('Map UA-CH headers', () => {
|
|||||||
|
|
||||||
uap = UAParser(headers2).withClientHints();
|
uap = UAParser(headers2).withClientHints();
|
||||||
|
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "110.0.0.0");
|
assert.strictEqual(uap.browser.version, "110.0.0.0");
|
||||||
assert.strictEqual(uap.browser.major, "110");
|
assert.strictEqual(uap.browser.major, "110");
|
||||||
assert.strictEqual(uap.cpu.architecture, "amd64");
|
assert.strictEqual(uap.cpu.architecture, CPUArch.X86_64);
|
||||||
assert.strictEqual(uap.device.type, "mobile");
|
assert.strictEqual(uap.device.type, DeviceType.MOBILE);
|
||||||
assert.strictEqual(uap.device.model, undefined);
|
assert.strictEqual(uap.device.model, undefined);
|
||||||
assert.strictEqual(uap.device.vendor, undefined);
|
assert.strictEqual(uap.device.vendor, undefined);
|
||||||
assert.strictEqual(uap.engine.name, 'Blink');
|
assert.strictEqual(uap.engine.name, EngineName.BLINK);
|
||||||
assert.strictEqual(uap.engine.version, '110.0.0.0');
|
assert.strictEqual(uap.engine.version, '110.0.0.0');
|
||||||
assert.strictEqual(uap.os.name, "Linux");
|
assert.strictEqual(uap.os.name, OSName.LINUX);
|
||||||
assert.strictEqual(uap.os.version, undefined);
|
assert.strictEqual(uap.os.version, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -117,10 +118,10 @@ describe('Map UA-CH headers', () => {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
assert.strictEqual(ua.os.is("macOS"), true);
|
assert.strictEqual(ua.os.is(OSName.MACOS), true);
|
||||||
assert.strictEqual(ua.cpu.is("arm"), true);
|
assert.strictEqual(ua.cpu.is(CPUArch.ARM), true);
|
||||||
assert.strictEqual(ua.device.is("mobile"), false);
|
assert.strictEqual(ua.device.is(DeviceType.MOBILE), false);
|
||||||
assert.strictEqual(ua.device.is("tablet"), false);
|
assert.strictEqual(ua.device.is(DeviceType.TABLET), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -139,11 +140,11 @@ describe('Map UA-CH headers', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
UAParser(FFVR).withClientHints().then(ua => {
|
UAParser(FFVR).withClientHints().then(ua => {
|
||||||
assert.strictEqual(ua.device.type, 'xr');
|
assert.strictEqual(ua.device.type, DeviceType.XR);
|
||||||
});
|
});
|
||||||
|
|
||||||
UAParser(FFEInk).withClientHints().then(ua => {
|
UAParser(FFEInk).withClientHints().then(ua => {
|
||||||
assert.strictEqual(ua.device.type, 'tablet');
|
assert.strictEqual(ua.device.type, DeviceType.TABLET);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ describe('Map UA-CH headers', () => {
|
|||||||
|
|
||||||
uap = UAParser(headers2).withClientHints();
|
uap = UAParser(headers2).withClientHints();
|
||||||
|
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, undefined);
|
assert.strictEqual(uap.browser.version, undefined);
|
||||||
assert.strictEqual(uap.browser.major, undefined);
|
assert.strictEqual(uap.browser.major, undefined);
|
||||||
});
|
});
|
||||||
@ -196,27 +197,27 @@ describe('Map UA-CH headers', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uap = UAParser(headers3a).withClientHints();
|
uap = UAParser(headers3a).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
||||||
|
|
||||||
uap = UAParser(headers3b).withClientHints();
|
uap = UAParser(headers3b).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
||||||
|
|
||||||
uap = UAParser(headers3c).withClientHints();
|
uap = UAParser(headers3c).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Chrome");
|
assert.strictEqual(uap.browser.name, BrowserName.CHROME);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
assert.strictEqual(uap.browser.version, "120.0.6099.132");
|
||||||
|
|
||||||
uap = UAParser(headers3d).withClientHints();
|
uap = UAParser(headers3d).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Edge");
|
assert.strictEqual(uap.browser.name, BrowserName.EDGE);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
||||||
|
|
||||||
uap = UAParser(headers3e).withClientHints();
|
uap = UAParser(headers3e).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Edge");
|
assert.strictEqual(uap.browser.name, BrowserName.EDGE);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
||||||
|
|
||||||
uap = UAParser(headers3f).withClientHints();
|
uap = UAParser(headers3f).withClientHints();
|
||||||
assert.strictEqual(uap.browser.name, "Edge");
|
assert.strictEqual(uap.browser.name, BrowserName.EDGE);
|
||||||
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
assert.strictEqual(uap.browser.version, "120.0.6099.133");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -235,169 +236,169 @@ describe('Identify vendor & type of device from given model name', () => {
|
|||||||
{
|
{
|
||||||
model: '220733SG',
|
model: '220733SG',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Xiaomi',
|
vendor : DeviceVendor.XIAOMI,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: '5087Z',
|
model: '5087Z',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'TCL',
|
vendor : DeviceVendor.TCL,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: '9137W',
|
model: '9137W',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'TCL',
|
vendor : DeviceVendor.TCL,
|
||||||
type : 'tablet'
|
type : DeviceType.TABLET
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'BE2015',
|
model: 'BE2015',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'OnePlus',
|
vendor : DeviceVendor.ONEPLUS,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'CPH2389',
|
model: 'CPH2389',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'OnePlus',
|
vendor : DeviceVendor.ONEPLUS,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Infinix X669C',
|
model: 'Infinix X669C',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Infinix',
|
vendor : DeviceVendor.INFINIX,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'itel L6502',
|
model: 'itel L6502',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'itel',
|
vendor : DeviceVendor.ITEL,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Lenovo TB-X606F',
|
model: 'Lenovo TB-X606F',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Lenovo',
|
vendor : DeviceVendor.LENOVO,
|
||||||
type : 'tablet'
|
type : DeviceType.TABLET
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'LM-Q720',
|
model: 'LM-Q720',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'LG',
|
vendor : DeviceVendor.LG,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'M2003J15SC',
|
model: 'M2003J15SC',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Xiaomi',
|
vendor : DeviceVendor.XIAOMI,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'MAR-LX1A',
|
model: 'MAR-LX1A',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Huawei',
|
vendor : DeviceVendor.HUAWEI,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'moto g(20)',
|
model: 'moto g(20)',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Motorola',
|
vendor : DeviceVendor.MOTOROLA,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Nokia C210',
|
model: 'Nokia C210',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Nokia',
|
vendor : DeviceVendor.NOKIA,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Pixel 8',
|
model: 'Pixel 8',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Google',
|
vendor : DeviceVendor.GOOGLE,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Redmi Note 9S',
|
model: 'Redmi Note 9S',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Xiaomi',
|
vendor : DeviceVendor.XIAOMI,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'RMX3830',
|
model: 'RMX3830',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Realme',
|
vendor : DeviceVendor.REALME,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'SM-S536DL',
|
model: 'SM-S536DL',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Samsung',
|
vendor : DeviceVendor.SAMSUNG,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'SM-S546VL',
|
model: 'SM-S546VL',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Samsung',
|
vendor : DeviceVendor.SAMSUNG,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'SM-T875',
|
model: 'SM-T875',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Samsung',
|
vendor : DeviceVendor.SAMSUNG,
|
||||||
type : 'tablet'
|
type : DeviceType.TABLET
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'STK-L21',
|
model: 'STK-L21',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Huawei',
|
vendor : DeviceVendor.HUAWEI,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'T430W',
|
model: 'T430W',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'TCL',
|
vendor : DeviceVendor.TCL,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'TECNO KI5k',
|
model: 'TECNO KI5k',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'TECNO',
|
vendor : DeviceVendor.TECNO,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'vivo 1820',
|
model: 'vivo 1820',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Vivo',
|
vendor : DeviceVendor.VIVO,
|
||||||
type : 'mobile'
|
type : DeviceType.MOBILE
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: 'Xbox',
|
model: 'Xbox',
|
||||||
expect: {
|
expect: {
|
||||||
vendor : 'Microsoft',
|
vendor : DeviceVendor.MICROSOFT,
|
||||||
type : 'console'
|
type : DeviceType.CONSOLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user