1- import robot = require( "@nut-tree/libnut" ) ;
1+ import libnut = require( "@nut-tree/libnut" ) ;
22import { Key } from "../../key.enum" ;
3- import { KeyboardAction } from "./robotjs -keyboard-action.class" ;
3+ import { KeyboardAction } from "./libnut -keyboard-action.class" ;
44
55jest . mock ( "@nut-tree/libnut" ) ;
66
77beforeEach ( ( ) => {
88 jest . resetAllMocks ( ) ;
99} ) ;
1010
11- describe ( "robotjs keyboard action" , ( ) => {
11+ describe ( "libnut keyboard action" , ( ) => {
1212 describe ( "click" , ( ) => {
13- it ( "should forward the keyTap call to robotjs for a known key" , ( ) => {
13+ it ( "should forward the keyTap call to libnut for a known key" , ( ) => {
1414 // GIVEN
1515 const SUT = new KeyboardAction ( ) ;
1616
1717 // WHEN
1818 SUT . click ( Key . A ) ;
1919
2020 // THEN
21- expect ( robot . keyTap ) . toBeCalledTimes ( 1 ) ;
21+ expect ( libnut . keyTap ) . toBeCalledTimes ( 1 ) ;
2222 } ) ;
2323
24- it ( "should reject on robotjs errors" , async ( ) => {
24+ it ( "should reject on libnut errors" , async ( ) => {
2525 // GIVEN
2626 const SUT = new KeyboardAction ( ) ;
27- robot . keyTap = jest . fn ( ( ) => {
27+ libnut . keyTap = jest . fn ( ( ) => {
2828 throw new Error ( "Test error" ) ;
2929 } ) ;
3030
@@ -34,20 +34,20 @@ describe("robotjs keyboard action", () => {
3434 expect ( SUT . click ( Key . A ) ) . rejects . toThrowError ( "Test error" ) ;
3535 } ) ;
3636
37- it ( "should not forward the keyTap call to robotjs for an unknown key" , ( ) => {
37+ it ( "should not forward the keyTap call to libnut for an unknown key" , ( ) => {
3838 // GIVEN
3939 const SUT = new KeyboardAction ( ) ;
4040
4141 // WHEN
4242 SUT . click ( Key . Add ) ;
4343
4444 // THEN
45- expect ( robot . keyTap ) . not . toBeCalled ( ) ;
45+ expect ( libnut . keyTap ) . not . toBeCalled ( ) ;
4646 } ) ;
4747 } ) ;
4848
4949 describe ( "type" , ( ) => {
50- it ( "should forward the type call to robotjs " , ( ) => {
50+ it ( "should forward the type call to libnut " , ( ) => {
5151 // GIVEN
5252 const SUT = new KeyboardAction ( ) ;
5353 const payload = "testInput" ;
@@ -56,14 +56,14 @@ describe("robotjs keyboard action", () => {
5656 SUT . type ( payload ) ;
5757
5858 // THEN
59- expect ( robot . typeString ) . toBeCalledTimes ( 1 ) ;
60- expect ( robot . typeString ) . toBeCalledWith ( payload ) ;
59+ expect ( libnut . typeString ) . toBeCalledTimes ( 1 ) ;
60+ expect ( libnut . typeString ) . toBeCalledWith ( payload ) ;
6161 } ) ;
6262
63- it ( "should reject on robotjs errors" , async ( ) => {
63+ it ( "should reject on libnut errors" , async ( ) => {
6464 // GIVEN
6565 const SUT = new KeyboardAction ( ) ;
66- robot . typeString = jest . fn ( ( ) => {
66+ libnut . typeString = jest . fn ( ( ) => {
6767 throw new Error ( "Test error" ) ;
6868 } ) ;
6969
@@ -75,16 +75,16 @@ describe("robotjs keyboard action", () => {
7575 } ) ;
7676
7777 describe ( "pressKey" , ( ) => {
78- it ( "should forward the pressKey call to robotjs for a known key" , ( ) => {
78+ it ( "should forward the pressKey call to libnut for a known key" , ( ) => {
7979 // GIVEN
8080 const SUT = new KeyboardAction ( ) ;
8181
8282 // WHEN
8383 SUT . pressKey ( Key . A ) ;
8484
8585 // THEN
86- expect ( robot . keyToggle ) . toBeCalledTimes ( 1 ) ;
87- expect ( robot . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "down" , [ ] ) ;
86+ expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
87+ expect ( libnut . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "down" , [ ] ) ;
8888 } ) ;
8989
9090 it ( "should treat a list of keys as modifiers + the actual key to press" , ( ) => {
@@ -95,26 +95,26 @@ describe("robotjs keyboard action", () => {
9595 SUT . pressKey ( Key . LeftControl , Key . A ) ;
9696
9797 // THEN
98- expect ( robot . keyToggle ) . toBeCalledTimes ( 1 ) ;
99- expect ( robot . keyToggle )
98+ expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
99+ expect ( libnut . keyToggle )
100100 . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "down" , [ KeyboardAction . keyLookup ( Key . LeftControl ) ] ) ;
101101 } ) ;
102102
103- it ( "should not forward the pressKey call to robotjs for an unknown key" , ( ) => {
103+ it ( "should not forward the pressKey call to libnut for an unknown key" , ( ) => {
104104 // GIVEN
105105 const SUT = new KeyboardAction ( ) ;
106106
107107 // WHEN
108108 SUT . pressKey ( Key . Add ) ;
109109
110110 // THEN
111- expect ( robot . keyToggle ) . not . toBeCalled ( ) ;
111+ expect ( libnut . keyToggle ) . not . toBeCalled ( ) ;
112112 } ) ;
113113
114- it ( "should reject on robotjs errors" , async ( ) => {
114+ it ( "should reject on libnut errors" , async ( ) => {
115115 // GIVEN
116116 const SUT = new KeyboardAction ( ) ;
117- robot . keyToggle = jest . fn ( ( ) => {
117+ libnut . keyToggle = jest . fn ( ( ) => {
118118 throw new Error ( "Test error" ) ;
119119 } ) ;
120120
@@ -126,16 +126,16 @@ describe("robotjs keyboard action", () => {
126126 } ) ;
127127
128128 describe ( "releaseKey" , ( ) => {
129- it ( "should forward the releaseKey call to robotjs for a known key" , ( ) => {
129+ it ( "should forward the releaseKey call to libnut for a known key" , ( ) => {
130130 // GIVEN
131131 const SUT = new KeyboardAction ( ) ;
132132
133133 // WHEN
134134 SUT . releaseKey ( Key . A ) ;
135135
136136 // THEN
137- expect ( robot . keyToggle ) . toBeCalledTimes ( 1 ) ;
138- expect ( robot . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "up" , [ ] ) ;
137+ expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
138+ expect ( libnut . keyToggle ) . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "up" , [ ] ) ;
139139 } ) ;
140140
141141 it ( "should treat a list of keys as modifiers + the actual key to release" , ( ) => {
@@ -146,26 +146,26 @@ describe("robotjs keyboard action", () => {
146146 SUT . releaseKey ( Key . LeftControl , Key . A ) ;
147147
148148 // THEN
149- expect ( robot . keyToggle ) . toBeCalledTimes ( 1 ) ;
150- expect ( robot . keyToggle )
149+ expect ( libnut . keyToggle ) . toBeCalledTimes ( 1 ) ;
150+ expect ( libnut . keyToggle )
151151 . toBeCalledWith ( KeyboardAction . keyLookup ( Key . A ) , "up" , [ KeyboardAction . keyLookup ( Key . LeftControl ) ] ) ;
152152 } ) ;
153153
154- it ( "should not forward the releaseKey call to robotjs for an unknown key" , ( ) => {
154+ it ( "should not forward the releaseKey call to libnut for an unknown key" , ( ) => {
155155 // GIVEN
156156 const SUT = new KeyboardAction ( ) ;
157157
158158 // WHEN
159159 SUT . releaseKey ( Key . Add ) ;
160160
161161 // THEN
162- expect ( robot . keyToggle ) . not . toBeCalled ( ) ;
162+ expect ( libnut . keyToggle ) . not . toBeCalled ( ) ;
163163 } ) ;
164164
165- it ( "should reject on robotjs errors" , async ( ) => {
165+ it ( "should reject on libnut errors" , async ( ) => {
166166 // GIVEN
167167 const SUT = new KeyboardAction ( ) ;
168- robot . keyToggle = jest . fn ( ( ) => {
168+ libnut . keyToggle = jest . fn ( ( ) => {
169169 throw new Error ( "Test error" ) ;
170170 } ) ;
171171
0 commit comments