├── .eslintignore ├── .npmignore ├── .npmrc ├── src ├── index.ts ├── index.browser.ts ├── __tests__ │ ├── desktop.test.ts │ ├── android.test.ts │ ├── other.test.ts │ ├── windows.test.ts │ ├── browser.e2e.test.ts │ ├── apple.test.ts │ └── amazon.test.ts └── isMobile.ts ├── prettier.config.js ├── types ├── index.d.ts ├── index.d.ts.map ├── isMobile.d.ts.map └── isMobile.d.ts ├── .dependabot └── config.yml ├── .eslintrc.js ├── tsconfig.json ├── jest.config.js ├── .gitignore ├── .github └── workflows │ ├── pull_request.yml │ └── release.yml ├── CONTRIBUTORS.md ├── LICENSE ├── package.json └── README.md /.eslintignore: -------------------------------------------------------------------------------- 1 | cjs 2 | dist 3 | esm 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.tsbuildinfo 2 | .cache 3 | coverage -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './isMobile'; 2 | export { default } from './isMobile'; 3 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = require('@spotify/web-scripts/config/prettier.config.js'); 2 | -------------------------------------------------------------------------------- /types/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './isMobile'; 2 | export { default } from './isMobile'; 3 | // # sourceMappingURL=index.d.ts.map 4 | -------------------------------------------------------------------------------- /.dependabot/config.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | update_configs: 3 | - package_manager: "javascript" 4 | directory: "/" 5 | update_schedule: "daily" 6 | -------------------------------------------------------------------------------- /types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"} -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ...require('@spotify/web-scripts/config/eslintrc.js'), 3 | rules: { 4 | 'no-redeclare': 'off', 5 | '@typescript-eslint/no-redeclare': ['error'], 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@spotify/web-scripts/config/tsconfig.json", 3 | "include": ["src"], 4 | "exclude": ["src/__tests__", "src/index.browser.ts"], 5 | "compilerOptions": { 6 | "target": "es3" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/src/__tests__'], 3 | transform: { 4 | '^.+\\.ts$': 'ts-jest', 5 | }, 6 | testRegex: '^.+\\.ts$', 7 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], 8 | preset: 'jest-puppeteer', 9 | }; 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated output 2 | cjs 3 | esm 4 | dist 5 | 6 | # TypeScript incremental compilation cache 7 | *.tsbuildinfo 8 | 9 | # Parcel cache 10 | .cache 11 | 12 | # Node modules 13 | node_modules 14 | 15 | # NPM lock file (we use Yarn's) 16 | package-lock.json 17 | 18 | # Logs 19 | npm-debug.log* 20 | yarn-debug.log* 21 | yarn-error.log* 22 | 23 | # Coverage 24 | coverage/ 25 | 26 | # Mac OS 27 | .DS_Store 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/pull_request.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - refs/pull/* 7 | pull_request: 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | strategy: 13 | matrix: 14 | node-version: [10, 12, 14] 15 | steps: 16 | - uses: actions/checkout@v2 17 | - uses: actions/setup-node@v1 18 | with: 19 | node-version: ${{ matrix.node-version }} 20 | - run: yarn install 21 | - run: yarn lint 22 | - run: yarn build 23 | - run: yarn test 24 | -------------------------------------------------------------------------------- /src/index.browser.ts: -------------------------------------------------------------------------------- 1 | import isMobile from './'; 2 | 3 | /** 4 | * This file is used to generate the browser version of this library. 5 | * It is compiled as `isMobile.min.js` into the `dist` directory. 6 | * 7 | * The `dist` directory is published to NPM so that the compiled file can 8 | * can be easily accessed by consumers of the library via the jsDelivr CDN. 9 | * 10 | * It is meant to be included via a ` 146 | 147 | 148 | 149 | 150 | 151 | ``` 152 | 153 | ### jsDelivr CDN [![](https://data.jsdelivr.com/v1/package/npm/ismobilejs/badge)](https://www.jsdelivr.com/package/npm/ismobilejs) 154 | 155 | Alternatively, you can include this library via [jsDelivr CDN](https://www.jsdelivr.com/package/npm/ismobilejs) in a `script` tag: 156 | 157 | `` 158 | 159 | **Visit the isMobile [jsDelivr page](https://www.jsdelivr.com/package/npm/ismobilejs) to get the most up-to-date URL pointing to the lastest version.** 160 | 161 | ## Building manually 162 | 163 | After checking out the repo, install dependencies: 164 | 165 | ```bash 166 | yarn install 167 | ``` 168 | 169 | Then build the library: 170 | 171 | ```bash 172 | yarn build 173 | ``` 174 | 175 | Three versions of the library will be generated: 176 | 177 | 1. `./cjs/index.js` - the CommonJS version of the library 178 | 2. `./esm/index.js` - the ESModule version of the library 179 | 3. `./dist/isMobile.min.js` - the browser version of the library 180 | 181 | Additionally, types will be output to `types`. 182 | 183 | ## Contributing 184 | 185 | This library uses Spotify's [web-scripts](https://github.com/spotify/web-scripts) project to build, lint, test, format and release the this library. 186 | 187 | You must use `yarn commit` rather than `git commit` to commit files. This enforced commit messages to following a specific format and enables automation of release notes and version bump. 188 | -------------------------------------------------------------------------------- /src/__tests__/amazon.test.ts: -------------------------------------------------------------------------------- 1 | import isMobile, { isMobileResult } from '../'; 2 | 3 | describe('Amazon', () => { 4 | let mobile: isMobileResult; 5 | let userAgent: string; 6 | 7 | describe('Amazon Kindle Fire User Agent', () => { 8 | beforeEach(() => { 9 | userAgent = 10 | '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'; 11 | mobile = isMobile(userAgent); 12 | }); 13 | 14 | test('should not be an Amazon Phone', () => { 15 | expect(mobile.amazon.phone).not.toBe(true); 16 | }); 17 | 18 | test('should be an Amazon Tablet', () => { 19 | expect(mobile.amazon.tablet).toBe(true); 20 | }); 21 | 22 | test('should be an Amazon device', () => { 23 | expect(mobile.amazon.device).toBe(true); 24 | }); 25 | 26 | test('should not be an Android Phone', () => { 27 | expect(mobile.android.phone).not.toBe(true); 28 | }); 29 | 30 | test('should be an Android Tablet', () => { 31 | expect(mobile.android.tablet).toBe(true); 32 | }); 33 | 34 | test('should be matched as Any Tablet', () => { 35 | expect(mobile.tablet).toBe(true); 36 | }); 37 | 38 | test('should be an Android device', () => { 39 | expect(mobile.android.device).toBe(true); 40 | }); 41 | }); 42 | 43 | describe('Amazon Kindle Fire HD User Agent', () => { 44 | beforeEach(() => { 45 | userAgent = 46 | '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'; 47 | mobile = isMobile(userAgent); 48 | }); 49 | 50 | test('should not be an Amazon Phone', () => { 51 | expect(mobile.amazon.phone).not.toBe(true); 52 | }); 53 | 54 | test('should be an Amazon Tablet', () => { 55 | expect(mobile.amazon.tablet).toBe(true); 56 | }); 57 | 58 | test('should be an Amazon device', () => { 59 | expect(mobile.amazon.device).toBe(true); 60 | }); 61 | 62 | test('should not be an Android Phone', () => { 63 | expect(mobile.android.phone).not.toBe(true); 64 | }); 65 | 66 | test('should be an Android Tablet', () => { 67 | expect(mobile.android.tablet).toBe(true); 68 | }); 69 | 70 | test('should be matched as Any Tablet', () => { 71 | expect(mobile.tablet).toBe(true); 72 | }); 73 | 74 | test('should be an Android device', () => { 75 | expect(mobile.android.device).toBe(true); 76 | }); 77 | }); 78 | 79 | describe('Amazon Kindle Fire HD 8.9inch User Agent', () => { 80 | beforeEach(() => { 81 | userAgent = 82 | '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'; 83 | mobile = isMobile(userAgent); 84 | }); 85 | 86 | test('should not be an Amazon Phone', () => { 87 | expect(mobile.amazon.phone).not.toBe(true); 88 | }); 89 | 90 | test('should be an Amazon Tablet', () => { 91 | expect(mobile.amazon.tablet).toBe(true); 92 | }); 93 | 94 | test('should be an Amazon device', () => { 95 | expect(mobile.amazon.device).toBe(true); 96 | }); 97 | 98 | test('should not be an Android Phone', () => { 99 | expect(mobile.android.phone).not.toBe(true); 100 | }); 101 | 102 | test('should be an Android Tablet', () => { 103 | expect(mobile.android.tablet).toBe(true); 104 | }); 105 | 106 | test('should be matched as Any Tablet', () => { 107 | expect(mobile.tablet).toBe(true); 108 | }); 109 | 110 | test('should be an Android device', () => { 111 | expect(mobile.android.device).toBe(true); 112 | }); 113 | }); 114 | 115 | describe('Amazon Kindle Fire HD 8.9inch 4G User Agent', () => { 116 | beforeEach(() => { 117 | userAgent = 118 | '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'; 119 | mobile = isMobile(userAgent); 120 | }); 121 | 122 | test('should not be an Amazon Phone', () => { 123 | expect(mobile.amazon.phone).not.toBe(true); 124 | }); 125 | 126 | test('should be an Amazon Tablet', () => { 127 | expect(mobile.amazon.tablet).toBe(true); 128 | }); 129 | 130 | test('should be an Amazon device', () => { 131 | expect(mobile.amazon.device).toBe(true); 132 | }); 133 | 134 | test('should not be an Android Phone', () => { 135 | expect(mobile.android.phone).not.toBe(true); 136 | }); 137 | 138 | test('should be an Android Tablet', () => { 139 | expect(mobile.android.tablet).toBe(true); 140 | }); 141 | 142 | test('should be matched as Any Tablet', () => { 143 | expect(mobile.tablet).toBe(true); 144 | }); 145 | 146 | test('should be an Android device', () => { 147 | expect(mobile.android.device).toBe(true); 148 | }); 149 | }); 150 | 151 | describe('Amazon Kindle Fire HD 7inch (3rd Generation) User Agent', () => { 152 | beforeEach(() => { 153 | userAgent = 154 | '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'; 155 | mobile = isMobile(userAgent); 156 | }); 157 | 158 | test('should not be an Amazon Phone', () => { 159 | expect(mobile.amazon.phone).not.toBe(true); 160 | }); 161 | 162 | test('should be an Amazon Tablet', () => { 163 | expect(mobile.amazon.tablet).toBe(true); 164 | }); 165 | 166 | test('should be an Amazon device', () => { 167 | expect(mobile.amazon.device).toBe(true); 168 | }); 169 | 170 | test('should not be an Android Phone', () => { 171 | expect(mobile.android.phone).not.toBe(true); 172 | }); 173 | 174 | test('should be an Android Tablet', () => { 175 | expect(mobile.android.tablet).toBe(true); 176 | }); 177 | 178 | test('should be matched as Any Tablet', () => { 179 | expect(mobile.tablet).toBe(true); 180 | }); 181 | 182 | test('should be an Android device', () => { 183 | expect(mobile.android.device).toBe(true); 184 | }); 185 | }); 186 | 187 | describe('Amazon Kindle Fire HDX 7inch (3rd Generation) User Agent', () => { 188 | beforeEach(() => { 189 | userAgent = 190 | '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'; 191 | mobile = isMobile(userAgent); 192 | }); 193 | 194 | test('should not be an Amazon Phone', () => { 195 | expect(mobile.amazon.phone).not.toBe(true); 196 | }); 197 | 198 | test('should be an Amazon Tablet', () => { 199 | expect(mobile.amazon.tablet).toBe(true); 200 | }); 201 | 202 | test('should be an Amazon device', () => { 203 | expect(mobile.amazon.device).toBe(true); 204 | }); 205 | 206 | test('should not be an Android Phone', () => { 207 | expect(mobile.android.phone).not.toBe(true); 208 | }); 209 | 210 | test('should be an Android Tablet', () => { 211 | expect(mobile.android.tablet).toBe(true); 212 | }); 213 | 214 | test('should be matched as Any Tablet', () => { 215 | expect(mobile.tablet).toBe(true); 216 | }); 217 | 218 | test('should be an Android device', () => { 219 | expect(mobile.android.device).toBe(true); 220 | }); 221 | }); 222 | 223 | describe('Amazon Kindle Fire HDX 7 (3rd Generation) 4G User Agent', () => { 224 | beforeEach(() => { 225 | userAgent = 226 | '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'; 227 | mobile = isMobile(userAgent); 228 | }); 229 | 230 | test('should not be an Amazon Phone', () => { 231 | expect(mobile.amazon.phone).not.toBe(true); 232 | }); 233 | 234 | test('should be an Amazon Tablet', () => { 235 | expect(mobile.amazon.tablet).toBe(true); 236 | }); 237 | 238 | test('should be an Amazon device', () => { 239 | expect(mobile.amazon.device).toBe(true); 240 | }); 241 | 242 | test('should not be an Android Phone', () => { 243 | expect(mobile.android.phone).not.toBe(true); 244 | }); 245 | 246 | test('should be an Android Tablet', () => { 247 | expect(mobile.android.tablet).toBe(true); 248 | }); 249 | 250 | test('should be matched as Any Tablet', () => { 251 | expect(mobile.tablet).toBe(true); 252 | }); 253 | 254 | test('should be an Android device', () => { 255 | expect(mobile.android.device).toBe(true); 256 | }); 257 | }); 258 | 259 | describe('Amazon Kindle Fire HDX 8.9inch (3rd Generation) User Agent', () => { 260 | beforeEach(() => { 261 | userAgent = 262 | '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'; 263 | mobile = isMobile(userAgent); 264 | }); 265 | 266 | test('should not be an Amazon Phone', () => { 267 | expect(mobile.amazon.phone).not.toBe(true); 268 | }); 269 | 270 | test('should be an Amazon Tablet', () => { 271 | expect(mobile.amazon.tablet).toBe(true); 272 | }); 273 | 274 | test('should be an Amazon device', () => { 275 | expect(mobile.amazon.device).toBe(true); 276 | }); 277 | 278 | test('should not be an Android Phone', () => { 279 | expect(mobile.android.phone).not.toBe(true); 280 | }); 281 | 282 | test('should be an Android Tablet', () => { 283 | expect(mobile.android.tablet).toBe(true); 284 | }); 285 | 286 | test('should be matched as Any Tablet', () => { 287 | expect(mobile.tablet).toBe(true); 288 | }); 289 | 290 | test('should be an Android device', () => { 291 | expect(mobile.android.device).toBe(true); 292 | }); 293 | }); 294 | 295 | describe('Amazon Kindle Fire HDX 8.9inch (3rd Generation) 4G User Agent', () => { 296 | beforeEach(() => { 297 | userAgent = 298 | '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'; 299 | mobile = isMobile(userAgent); 300 | }); 301 | 302 | test('should not be an Amazon Phone', () => { 303 | expect(mobile.amazon.phone).not.toBe(true); 304 | }); 305 | 306 | test('should be an Amazon Tablet', () => { 307 | expect(mobile.amazon.tablet).toBe(true); 308 | }); 309 | 310 | test('should be an Amazon device', () => { 311 | expect(mobile.amazon.device).toBe(true); 312 | }); 313 | 314 | test('should not be an Android Phone', () => { 315 | expect(mobile.android.phone).not.toBe(true); 316 | }); 317 | 318 | test('should be an Android Tablet', () => { 319 | expect(mobile.android.tablet).toBe(true); 320 | }); 321 | 322 | test('should be matched as Any Tablet', () => { 323 | expect(mobile.tablet).toBe(true); 324 | }); 325 | 326 | test('should be an Android device', () => { 327 | expect(mobile.android.device).toBe(true); 328 | }); 329 | }); 330 | 331 | describe('Amazon Fire HD 6 (4th Generation) User Agent', () => { 332 | beforeEach(() => { 333 | userAgent = 334 | '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'; 335 | mobile = isMobile(userAgent); 336 | }); 337 | 338 | test('should not be an Amazon Phone', () => { 339 | expect(mobile.amazon.phone).not.toBe(true); 340 | }); 341 | 342 | test('should be an Amazon Tablet', () => { 343 | expect(mobile.amazon.tablet).toBe(true); 344 | }); 345 | 346 | test('should be an Amazon device', () => { 347 | expect(mobile.amazon.device).toBe(true); 348 | }); 349 | 350 | test('should not be an Android Phone', () => { 351 | expect(mobile.android.phone).not.toBe(true); 352 | }); 353 | 354 | test('should be an Android Tablet', () => { 355 | expect(mobile.android.tablet).toBe(true); 356 | }); 357 | 358 | test('should be matched as Any Tablet', () => { 359 | expect(mobile.tablet).toBe(true); 360 | }); 361 | 362 | test('should be an Android device', () => { 363 | expect(mobile.android.device).toBe(true); 364 | }); 365 | }); 366 | 367 | describe('Amazon Fire HD 7 (4th Generation) User Agent', () => { 368 | beforeEach(() => { 369 | userAgent = 370 | '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'; 371 | mobile = isMobile(userAgent); 372 | }); 373 | 374 | test('should not be an Amazon Phone', () => { 375 | expect(mobile.amazon.phone).not.toBe(true); 376 | }); 377 | 378 | test('should be an Amazon Tablet', () => { 379 | expect(mobile.amazon.tablet).toBe(true); 380 | }); 381 | 382 | test('should be an Amazon device', () => { 383 | expect(mobile.amazon.device).toBe(true); 384 | }); 385 | 386 | test('should not be an Android Phone', () => { 387 | expect(mobile.android.phone).not.toBe(true); 388 | }); 389 | 390 | test('should be an Android Tablet', () => { 391 | expect(mobile.android.tablet).toBe(true); 392 | }); 393 | 394 | test('should be matched as Any Tablet', () => { 395 | expect(mobile.tablet).toBe(true); 396 | }); 397 | 398 | test('should be an Android device', () => { 399 | expect(mobile.android.device).toBe(true); 400 | }); 401 | }); 402 | 403 | describe('Amazon Fire HDX 8.9 (4th Generation) User Agent', () => { 404 | beforeEach(() => { 405 | userAgent = 406 | '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'; 407 | mobile = isMobile(userAgent); 408 | }); 409 | 410 | test('should not be an Amazon Phone', () => { 411 | expect(mobile.amazon.phone).not.toBe(true); 412 | }); 413 | 414 | test('should be an Amazon Tablet', () => { 415 | expect(mobile.amazon.tablet).toBe(true); 416 | }); 417 | 418 | test('should be an Amazon device', () => { 419 | expect(mobile.amazon.device).toBe(true); 420 | }); 421 | 422 | test('should not be an Android Phone', () => { 423 | expect(mobile.android.phone).not.toBe(true); 424 | }); 425 | 426 | test('should be an Android Tablet', () => { 427 | expect(mobile.android.tablet).toBe(true); 428 | }); 429 | 430 | test('should be matched as Any Tablet', () => { 431 | expect(mobile.tablet).toBe(true); 432 | }); 433 | 434 | test('should be an Android device', () => { 435 | expect(mobile.android.device).toBe(true); 436 | }); 437 | }); 438 | 439 | describe('Amazon Fire HDX 8.9 (4th Generation) 4G User Agent', () => { 440 | beforeEach(() => { 441 | userAgent = 442 | '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'; 443 | mobile = isMobile(userAgent); 444 | }); 445 | 446 | test('should not be an Amazon Phone', () => { 447 | expect(mobile.amazon.phone).not.toBe(true); 448 | }); 449 | 450 | test('should be an Amazon Tablet', () => { 451 | expect(mobile.amazon.tablet).toBe(true); 452 | }); 453 | 454 | test('should be an Amazon device', () => { 455 | expect(mobile.amazon.device).toBe(true); 456 | }); 457 | 458 | test('should not be an Android Phone', () => { 459 | expect(mobile.android.phone).not.toBe(true); 460 | }); 461 | 462 | test('should be an Android Tablet', () => { 463 | expect(mobile.android.tablet).toBe(true); 464 | }); 465 | 466 | test('should be matched as Any Tablet', () => { 467 | expect(mobile.tablet).toBe(true); 468 | }); 469 | 470 | test('should be an Android device', () => { 471 | expect(mobile.android.device).toBe(true); 472 | }); 473 | }); 474 | 475 | describe('Amazon Fire Phone User Agent', () => { 476 | beforeEach(() => { 477 | userAgent = 478 | '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'; 479 | mobile = isMobile(userAgent); 480 | }); 481 | 482 | test('should be an Amazon Phone', () => { 483 | expect(mobile.amazon.phone).toBe(true); 484 | }); 485 | 486 | test('should not be an Amazon Tablet', () => { 487 | expect(mobile.amazon.tablet).not.toBe(true); 488 | }); 489 | 490 | test('should be an Amazon device', () => { 491 | expect(mobile.amazon.device).toBe(true); 492 | }); 493 | 494 | test('should be an Android Phone', () => { 495 | expect(mobile.android.phone).toBe(true); 496 | }); 497 | 498 | test('should not be an Android Tablet', () => { 499 | expect(mobile.android.tablet).not.toBe(true); 500 | }); 501 | 502 | test('should be matched as Any Phone', () => { 503 | expect(mobile.phone).toBe(true); 504 | }); 505 | 506 | test('should be an Android device', () => { 507 | expect(mobile.android.device).toBe(true); 508 | }); 509 | }); 510 | 511 | describe('Amazon Fire Generic Phone User Agent', () => { 512 | beforeEach(() => { 513 | userAgent = 514 | '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'; 515 | mobile = isMobile(userAgent); 516 | }); 517 | 518 | test('should be an Amazon Phone', () => { 519 | expect(mobile.amazon.phone).toBe(true); 520 | }); 521 | 522 | test('should not be an Amazon Tablet', () => { 523 | expect(mobile.amazon.tablet).not.toBe(true); 524 | }); 525 | 526 | test('should be an Amazon device', () => { 527 | expect(mobile.amazon.device).toBe(true); 528 | }); 529 | 530 | test('should be an Android Phone', () => { 531 | expect(mobile.android.phone).toBe(true); 532 | }); 533 | 534 | test('should not be an Android Tablet', () => { 535 | expect(mobile.android.tablet).not.toBe(true); 536 | }); 537 | 538 | test('should be matched as Any Phone', () => { 539 | expect(mobile.phone).toBe(true); 540 | }); 541 | 542 | test('should be an Android device', () => { 543 | expect(mobile.android.device).toBe(true); 544 | }); 545 | }); 546 | }); 547 | --------------------------------------------------------------------------------