Skip to content

Commit b3b8935

Browse files
author
Zaydek Michels-Gualtieri
committed
Updated some test suites to rely on mockUserAgent
1 parent 8fbcd4d commit b3b8935

4 files changed

Lines changed: 12 additions & 32 deletions

File tree

src/RichTextEditor/utils/keyDownTypeFor/history.test.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
import history from "./history"
22
import keyCodeFor from "lib/Client/keyCodeFor"
33

4-
// Mocks a non-macOS user agent.
5-
function mockNonMacOS() {
6-
Object.defineProperty(window.navigator, "userAgent", {
7-
value: "...",
8-
configurable: true,
9-
})
10-
}
11-
12-
// Mocks a macOS user agent.
13-
function mockMacOS() {
14-
Object.defineProperty(window.navigator, "userAgent", {
15-
value: "... Mac OS X ...",
16-
configurable: true,
17-
})
18-
}
4+
import { // Unsorted
5+
mockNonMacOS,
6+
mockMacOS,
7+
} from "lib/Client/mockUserAgent"
198

209
test("undo(...); non-macOS", () => {
2110
mockNonMacOS()

src/lib/Client/isCtrlOrMetaKey/index.test.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import isCtrlOrMetaKey from "./index"
22

3-
// Mocks a non-macOS user agent.
4-
function mockNonMacOS() {
5-
Object.defineProperty(window.navigator, "userAgent", {
6-
value: "...",
7-
configurable: true,
8-
})
9-
}
10-
11-
// Mocks a macOS user agent.
12-
function mockMacOS() {
13-
Object.defineProperty(window.navigator, "userAgent", {
14-
value: "... Mac OS X ...",
15-
configurable: true,
16-
})
17-
}
3+
import { // Unsorted
4+
mockNonMacOS,
5+
mockMacOS,
6+
} from "lib/Client/mockUserAgent"
187

198
test("non-macOS", () => {
209
mockNonMacOS()

src/lib/Client/mockUserAgent/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Mocks a non-macOS user agent.
1+
// Mocks a non-macOS user agent; for testing purposes.
22
export function mockNonMacOS() {
33
Object.defineProperty(window.navigator, "userAgent", {
44
value: "...",
55
configurable: true,
66
})
77
}
88

9-
// Mocks a macOS user agent.
9+
// Mocks a macOS user agent; for testing purposes.
1010
export function mockMacOS() {
1111
Object.defineProperty(window.navigator, "userAgent", {
1212
value: "... Mac OS X ...",

src/lib/Client/userAgent/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ function testUserAgent(substr) {
55
return navigator.userAgent.indexOf(substr) >= 0
66
}
77

8+
// TODO: Add testedAppleDevice?
9+
// TODO: Add testedAndroidDevice?
810
const userAgent = {
911
// https://apple.com
1012
isAAPL: testUserAgent("Mac OS X"),

0 commit comments

Comments
 (0)