|
1 | | -// NOTE: import userAgent from "..." breaks the test runner. |
| 1 | +import userAgent from "./index" |
| 2 | + |
| 3 | +import { // Unsorted |
| 4 | + mockNonMacOS, |
| 5 | + mockMacOS, |
| 6 | +} from "lib/Client/mockUserAgent" |
2 | 7 |
|
3 | | -// https://stackoverflow.com/a/25518045 |
4 | 8 | test("isAAPL=false", () => { |
5 | | - Object.defineProperty(window.navigator, "userAgent", { |
6 | | - value: "...", |
7 | | - configurable: true, |
8 | | - }) |
9 | | - const isAAPL = navigator.userAgent.indexOf("Mac OS X") >= 0 |
10 | | - const userAgent = { isAAPL } |
| 9 | + mockNonMacOS() |
11 | 10 | expect(userAgent.isAAPL).not.toBeTruthy() |
12 | 11 | }) |
13 | 12 |
|
14 | 13 | test("isAAPL=true", () => { |
15 | | - Object.defineProperty(window.navigator, "userAgent", { |
16 | | - value: "... Mac OS X ...", |
17 | | - configurable: true, |
18 | | - }) |
19 | | - const isAAPL = navigator.userAgent.indexOf("Mac OS X") >= 0 |
20 | | - const userAgent = { isAAPL } |
| 14 | + mockMacOS() |
21 | 15 | expect(userAgent.isAAPL).toBeTruthy() |
22 | 16 | }) |
23 | | - |
24 | | -test("isGOOG=false", () => { |
25 | | - Object.defineProperty(window.navigator, "userAgent", { |
26 | | - value: "...", |
27 | | - configurable: true, |
28 | | - }) |
29 | | - const isGOOG = navigator.userAgent.indexOf("Android") >= 0 |
30 | | - const userAgent = { isGOOG } |
31 | | - expect(userAgent.isGOOG).not.toBeTruthy() |
32 | | -}) |
33 | | - |
34 | | -test("isGOOG=true", () => { |
35 | | - Object.defineProperty(window.navigator, "userAgent", { |
36 | | - value: "... Android ...", |
37 | | - configurable: true, |
38 | | - }) |
39 | | - const isGOOG = navigator.userAgent.indexOf("Android") >= 0 |
40 | | - const userAgent = { isGOOG } |
41 | | - expect(userAgent.isGOOG).toBeTruthy() |
42 | | -}) |
0 commit comments