-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.ts
29 lines (23 loc) · 844 Bytes
/
util.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { ClientFunction } from 'testcafe'
module.exports = {
// Increment a letter; used by getNewName()
getNextChar: function (char) {
if (char === 'z') {
return 'a';
}
if (char === 'Z') {
return 'A';
}
return String.fromCharCode(char.charCodeAt(0) + 1);
},
// Transform a device name by incrementing its last letter
getNewName: function (originalName) {
const prefix = originalName.substring(0, originalName.length - 1)
const lastChar = originalName.substring(originalName.length - 1)
return prefix + this.getNextChar(lastChar)
},
// Get the current URL from the browser
getPageUrl: ClientFunction(() => window.location.href),
// Reload the current page
reloadPage: ClientFunction(() => location.reload())
}