Skip to content

Commit ce3165e

Browse files
replace key names with proper unicode chars
webdriverio/recorder-extension#4
1 parent 8df2c89 commit ce3165e

File tree

2 files changed

+66
-70
lines changed

2 files changed

+66
-70
lines changed

src/constants.ts

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,67 @@
11
export const SUPPORTED_KEYS = {
2-
null: 'NULL',
3-
cancel: 'CANCEL',
4-
help: 'HELP',
5-
back_space: 'BACK_SPACE',
6-
tab: 'TAB',
7-
clear: 'CLEAR',
8-
return: 'RETURN',
9-
enter: 'ENTER',
10-
shift: 'SHIFT',
11-
control: 'CONTROL',
12-
alt: 'ALT',
13-
pause: 'PAUSE',
14-
escape: 'ESCAPE',
15-
space: 'SPACE',
16-
page_up: 'PAGE_UP',
17-
page_down: 'PAGE_DOWN',
18-
end: 'END',
19-
home: 'HOME',
20-
arrow_left: 'ARROW_LEFT',
21-
left: 'LEFT',
22-
arrow_up: 'ARROW_UP',
23-
up: 'UP',
24-
arrow_right: 'ARROW_RIGHT',
25-
right: 'RIGHT',
26-
arrow_down: 'ARROW_DOWN',
27-
down: 'DOWN',
28-
insert: 'INSERT',
29-
delete: 'DELETE',
30-
semicolon: 'SEMICOLON',
31-
equals: 'EQUALS',
2+
null: '\uE000',
3+
cancel: '\uE001',
4+
help: '\uE002',
5+
back_space: '\uE003',
6+
tab: '\uE004',
7+
clear: '\uE005',
8+
return: '\uE006',
9+
enter: '\uE007',
10+
shift: '\uE008',
11+
control: '\uE009',
12+
alt: '\uE00A',
13+
pause: '\uE00B',
14+
escape: '\uE00C',
15+
space: '\uE00D',
16+
page_up: '\uE00E',
17+
page_down: '\uE00F',
18+
end: '\uE010',
19+
home: '\uE011',
20+
arrow_left: '\uE012',
21+
left: '\uE012',
22+
arrow_up: '\uE013',
23+
up: '\uE013',
24+
arrow_right: '\uE014',
25+
right: '\uE014',
26+
arrow_down: '\uE015',
27+
down: '\uE015',
28+
insert: '\uE016',
29+
delete: '\uE017',
30+
semicolon: '\uE018',
31+
equals: '\uE019',
3232

33-
numpad0: 'NUMPAD0',
34-
numpad1: 'NUMPAD1',
35-
numpad2: 'NUMPAD2',
36-
numpad3: 'NUMPAD3',
37-
numpad4: 'NUMPAD4',
38-
numpad5: 'NUMPAD5',
39-
numpad6: 'NUMPAD6',
40-
numpad7: 'NUMPAD7',
41-
numpad8: 'NUMPAD8',
42-
numpad9: 'NUMPAD9',
43-
multiply: 'MULTIPLY',
44-
add: 'ADD',
45-
separator: 'SEPARATOR',
46-
subtract: 'SUBTRACT',
47-
decimal: 'DECIMAL',
48-
divide: 'DIVIDE',
33+
numpad0: '\uE01A',
34+
numpad1: '\uE01B',
35+
numpad2: '\uE01C',
36+
numpad3: '\uE01D',
37+
numpad4: '\uE01E',
38+
numpad5: '\uE01F',
39+
numpad6: '\uE020',
40+
numpad7: '\uE021',
41+
numpad8: '\uE022',
42+
numpad9: '\uE023',
43+
multiply: '\uE024',
44+
add: '\uE025',
45+
separator: '\uE026',
46+
subtract: '\uE027',
47+
decimal: '\uE028',
48+
divide: '\uE029',
4949

50-
f1: 'F1',
51-
f2: 'F2',
52-
f3: 'F3',
53-
f4: 'F4',
54-
f5: 'F5',
55-
f6: 'F6',
56-
f7: 'F7',
57-
f8: 'F8',
58-
f9: 'F9',
59-
f10: 'F10',
60-
f11: 'F11',
61-
f12: 'F12',
50+
f1: '\uE031',
51+
f2: '\uE032',
52+
f3: '\uE033',
53+
f4: '\uE034',
54+
f5: '\uE035',
55+
f6: '\uE036',
56+
f7: '\uE037',
57+
f8: '\uE038',
58+
f9: '\uE039',
59+
f10: '\uE03A',
60+
f11: '\uE03B',
61+
f12: '\uE03C',
6262

63-
command: 'COMMAND',
64-
meta: 'META',
63+
command: '\uE03D',
64+
meta: '\uE03D'
6565
} as const
6666

6767
export const DEFAULT_OUTPUT_FOLDER = 'wdio'

test/stringifyExtension.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('StringifyExtension', () => {
103103
'await browser.performActions([{\n' +
104104
' type: \'key\',\n' +
105105
' id: \'keyboard\',\n' +
106-
' actions: [{ type: \'keyDown\', value: \'ENTER\' }]\n' +
106+
' actions: [{ type: \'keyDown\', value: \'\uE007\' }]\n' +
107107
'}])\n'
108108
)
109109
})
@@ -135,7 +135,7 @@ describe('StringifyExtension', () => {
135135
'await browser.performActions([{\n' +
136136
' type: \'key\',\n' +
137137
' id: \'keyboard\',\n' +
138-
' actions: [{ type: \'keyUp\', value: \'ENTER\' }]\n' +
138+
' actions: [{ type: \'keyUp\', value: \'\uE007\' }]\n' +
139139
'}])\n'
140140
)
141141
})
@@ -202,8 +202,7 @@ describe('StringifyExtension', () => {
202202
const writer = new InMemoryLineWriter(' ')
203203
await ext.stringifyStep(writer, step, flow)
204204
expect(writer.toString()).toBe(
205-
'await browser.$("#test").waitForExist()\n' +
206-
'await expect(browser.$("#test")).toBeElementsArrayOfSize(2)\n'
205+
'await expect(browser.$$("#test")).toBeElementsArrayOfSize(2)\n'
207206
)
208207
})
209208

@@ -220,8 +219,7 @@ describe('StringifyExtension', () => {
220219
const writer = new InMemoryLineWriter(' ')
221220
await ext.stringifyStep(writer, step, flow)
222221
expect(writer.toString()).toBe(
223-
'await browser.$("#test").waitForExist({ timeout: 2000 })\n' +
224-
'await expect(browser.$("#test")).toBeElementsArrayOfSize(2)\n'
222+
'await expect(browser.$$("#test")).toBeElementsArrayOfSize(2, { timeout: 2000 })\n'
225223
)
226224
})
227225

@@ -237,8 +235,7 @@ describe('StringifyExtension', () => {
237235
const writer = new InMemoryLineWriter(' ')
238236
await ext.stringifyStep(writer, step, flow)
239237
expect(writer.toString()).toBe(
240-
'await browser.$("#test").waitForExist()\n' +
241-
'await expect(browser.$("#test")).toBeElementsArrayOfSize({ lte: 2 })\n'
238+
'await expect(browser.$$("#test")).toBeElementsArrayOfSize({ lte: 2 })\n'
242239
)
243240
})
244241

@@ -254,8 +251,7 @@ describe('StringifyExtension', () => {
254251
const writer = new InMemoryLineWriter(' ')
255252
await ext.stringifyStep(writer, step, flow)
256253
expect(writer.toString()).toBe(
257-
'await browser.$("#test").waitForExist()\n' +
258-
'await expect(browser.$("#test")).toBeElementsArrayOfSize({ gte: 2 })\n'
254+
'await expect(browser.$$("#test")).toBeElementsArrayOfSize({ gte: 2 })\n'
259255
)
260256
})
261257

0 commit comments

Comments
 (0)