@@ -10,12 +10,12 @@ beforeEach(() => {
10
10
11
11
describe ( "libnut keyboard action" , ( ) => {
12
12
describe ( "click" , ( ) => {
13
- it ( "should forward the keyTap call to libnut for a known key" , ( ) => {
13
+ it ( "should forward the keyTap call to libnut for a known key" , async ( ) => {
14
14
// GIVEN
15
15
const SUT = new KeyboardAction ( ) ;
16
16
17
17
// WHEN
18
- SUT . click ( Key . A ) ;
18
+ await SUT . click ( Key . A ) ;
19
19
20
20
// THEN
21
21
expect ( libnut . keyTap ) . toBeCalledTimes ( 1 ) ;
@@ -31,29 +31,29 @@ describe("libnut keyboard action", () => {
31
31
// WHEN
32
32
33
33
// THEN
34
- expect ( SUT . click ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
34
+ await expect ( SUT . click ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
35
35
} ) ;
36
36
37
- it ( "should not forward the keyTap call to libnut for an unknown key" , ( ) => {
37
+ it ( "should not forward the keyTap call to libnut for an unknown key" , async ( ) => {
38
38
// GIVEN
39
39
const SUT = new KeyboardAction ( ) ;
40
40
41
41
// WHEN
42
- SUT . click ( Key . Add ) ;
42
+ await SUT . click ( Key . Pause ) ;
43
43
44
44
// THEN
45
45
expect ( libnut . keyTap ) . not . toBeCalled ( ) ;
46
46
} ) ;
47
47
} ) ;
48
48
49
49
describe ( "type" , ( ) => {
50
- it ( "should forward the type call to libnut" , ( ) => {
50
+ it ( "should forward the type call to libnut" , async ( ) => {
51
51
// GIVEN
52
52
const SUT = new KeyboardAction ( ) ;
53
53
const payload = "testInput" ;
54
54
55
55
// WHEN
56
- SUT . type ( payload ) ;
56
+ await SUT . type ( payload ) ;
57
57
58
58
// THEN
59
59
expect ( libnut . typeString ) . toBeCalledTimes ( 1 ) ;
@@ -70,42 +70,42 @@ describe("libnut keyboard action", () => {
70
70
// WHEN
71
71
72
72
// THEN
73
- expect ( SUT . type ( "foo" ) ) . rejects . toThrowError ( "Test error" ) ;
73
+ await expect ( SUT . type ( "foo" ) ) . rejects . toThrowError ( "Test error" ) ;
74
74
} ) ;
75
75
} ) ;
76
76
77
77
describe ( "pressKey" , ( ) => {
78
- it ( "should forward the pressKey call to libnut for a known key" , ( ) => {
78
+ it ( "should forward the pressKey call to libnut for a known key" , async ( ) => {
79
79
// GIVEN
80
80
const SUT = new KeyboardAction ( ) ;
81
81
82
82
// WHEN
83
- SUT . pressKey ( Key . A ) ;
83
+ await SUT . pressKey ( Key . A ) ;
84
84
85
85
// THEN
86
86
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
87
87
expect ( libnut . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "down" , [ ] ) ;
88
88
} ) ;
89
89
90
- it ( "should treat a list of keys as modifiers + the actual key to press" , ( ) => {
90
+ it ( "should treat a list of keys as modifiers + the actual key to press" , async ( ) => {
91
91
// GIVEN
92
92
const SUT = new KeyboardAction ( ) ;
93
93
94
94
// WHEN
95
- SUT . pressKey ( Key . LeftControl , Key . A ) ;
95
+ await SUT . pressKey ( Key . LeftControl , Key . A ) ;
96
96
97
97
// THEN
98
98
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
99
99
expect ( libnut . keyToggle )
100
100
. toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "down" , [ KeyboardAction . keyLookup ( Key . LeftControl ) ] ) ;
101
101
} ) ;
102
102
103
- it ( "should not forward the pressKey call to libnut for an unknown key" , ( ) => {
103
+ it ( "should not forward the pressKey call to libnut for an unknown key" , async ( ) => {
104
104
// GIVEN
105
105
const SUT = new KeyboardAction ( ) ;
106
106
107
107
// WHEN
108
- SUT . pressKey ( Key . Add ) ;
108
+ await SUT . pressKey ( Key . Pause ) ;
109
109
110
110
// THEN
111
111
expect ( libnut . keyToggle ) . not . toBeCalled ( ) ;
@@ -121,42 +121,42 @@ describe("libnut keyboard action", () => {
121
121
// WHEN
122
122
123
123
// THEN
124
- expect ( SUT . pressKey ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
124
+ await expect ( SUT . pressKey ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
125
125
} ) ;
126
126
} ) ;
127
127
128
128
describe ( "releaseKey" , ( ) => {
129
- it ( "should forward the releaseKey call to libnut for a known key" , ( ) => {
129
+ it ( "should forward the releaseKey call to libnut for a known key" , async ( ) => {
130
130
// GIVEN
131
131
const SUT = new KeyboardAction ( ) ;
132
132
133
133
// WHEN
134
- SUT . releaseKey ( Key . A ) ;
134
+ await SUT . releaseKey ( Key . A ) ;
135
135
136
136
// THEN
137
137
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
138
138
expect ( libnut . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "up" , [ ] ) ;
139
139
} ) ;
140
140
141
- it ( "should treat a list of keys as modifiers + the actual key to release" , ( ) => {
141
+ it ( "should treat a list of keys as modifiers + the actual key to release" , async ( ) => {
142
142
// GIVEN
143
143
const SUT = new KeyboardAction ( ) ;
144
144
145
145
// WHEN
146
- SUT . releaseKey ( Key . LeftControl , Key . A ) ;
146
+ await SUT . releaseKey ( Key . LeftControl , Key . A ) ;
147
147
148
148
// THEN
149
149
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
150
150
expect ( libnut . keyToggle )
151
151
. toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "up" , [ KeyboardAction . keyLookup ( Key . LeftControl ) ] ) ;
152
152
} ) ;
153
153
154
- it ( "should not forward the releaseKey call to libnut for an unknown key" , ( ) => {
154
+ it ( "should not forward the releaseKey call to libnut for an unknown key" , async ( ) => {
155
155
// GIVEN
156
156
const SUT = new KeyboardAction ( ) ;
157
157
158
158
// WHEN
159
- SUT . releaseKey ( Key . Add ) ;
159
+ await SUT . releaseKey ( Key . Pause ) ;
160
160
161
161
// THEN
162
162
expect ( libnut . keyToggle ) . not . toBeCalled ( ) ;
@@ -172,29 +172,29 @@ describe("libnut keyboard action", () => {
172
172
// WHEN
173
173
174
174
// THEN
175
- expect ( SUT . releaseKey ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
175
+ await expect ( SUT . releaseKey ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
176
176
} ) ;
177
177
} ) ;
178
178
179
179
describe ( "bugfix #260" , ( ) => {
180
- it ( "should forward the pressKey call to libnut for 'delete'" , ( ) => {
180
+ it ( "should forward the pressKey call to libnut for 'delete'" , async ( ) => {
181
181
// GIVEN
182
182
const SUT = new KeyboardAction ( ) ;
183
183
184
184
// WHEN
185
- SUT . pressKey ( Key . Delete ) ;
185
+ await SUT . pressKey ( Key . Delete ) ;
186
186
187
187
// THEN
188
188
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
189
189
expect ( libnut . keyToggle ) . toBeCalledWith ( "delete" , "down" , [ ] ) ;
190
190
} ) ;
191
191
192
- it ( "should forward the releaseKey call to libnut for 'delete'" , ( ) => {
192
+ it ( "should forward the releaseKey call to libnut for 'delete'" , async ( ) => {
193
193
// GIVEN
194
194
const SUT = new KeyboardAction ( ) ;
195
195
196
196
// WHEN
197
- SUT . releaseKey ( Key . Delete ) ;
197
+ await SUT . releaseKey ( Key . Delete ) ;
198
198
199
199
// THEN
200
200
expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
0 commit comments