@@ -50,7 +50,7 @@ makeConnectionTests('Initalize Tests', function () {
50
50
} ) ;
51
51
this . test . conn . sendResponse ( {
52
52
requestId : '123' ,
53
- hook : " gotham.activated" ,
53
+ hook : ' gotham.activated' ,
54
54
type : 8
55
55
} ) ;
56
56
expect ( p ) . to . eventually . equal ( true ) ;
@@ -65,7 +65,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
65
65
this . test . module . declareFunction ( 'test_fn' , ( ) => { } ) ;
66
66
const message = this . test . getLatestSent ( ) ;
67
67
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
68
- function : " test_fn" ,
68
+ function : ' test_fn' ,
69
69
type : 9
70
70
} ) ;
71
71
} ) ;
@@ -75,7 +75,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
75
75
this . test . module . callFunction ( 'module.test_fn' ) ;
76
76
const message = this . test . getLatestSent ( ) ;
77
77
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
78
- function : " module.test_fn" ,
78
+ function : ' module.test_fn' ,
79
79
type : 3 ,
80
80
arguments : { }
81
81
} ) ;
@@ -88,7 +88,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
88
88
} ) ;
89
89
const message = this . test . getLatestSent ( ) ;
90
90
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
91
- function : " module.test_fn" ,
91
+ function : ' module.test_fn' ,
92
92
type : 3 ,
93
93
arguments : {
94
94
a : 1 ,
@@ -101,7 +101,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
101
101
this . test . module . registerHook ( 'test_hook' , ( ) => { } ) ;
102
102
const message = this . test . getLatestSent ( ) ;
103
103
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
104
- hook : " test_hook" ,
104
+ hook : ' test_hook' ,
105
105
type : 5 ,
106
106
} ) ;
107
107
} ) ;
@@ -111,89 +111,92 @@ makeConnectionTests('Test if requests constructed correctly', function () {
111
111
const message = this . test . getLatestSent ( ) ;
112
112
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
113
113
type : 7 ,
114
- hook : " test_hook" ,
114
+ hook : ' test_hook' ,
115
115
} ) ;
116
116
} ) ;
117
117
} ) ;
118
118
119
119
120
- makeConnectionTests ( 'Test if responses from gotham parsed correctly' , async function ( ) {
121
- it ( 'declareFunction' , async function ( ) {
122
- const p = this . test . module . declareFunction ( 'test_fn' , ( ) => { } ) ;
123
- const requestId = this . test . getLatestSent ( ) . requestId ;
124
- await sleep ( 0 ) ;
125
- this . test . conn . sendResponse ( {
126
- requestId,
127
- type : 10 ,
128
- function : 'test_fn'
129
- } ) ;
130
- return expect ( p ) . to . eventually . equal ( true ) ;
131
- } ) ;
132
- it ( 'hookRegistered' , async function ( ) {
133
- const p = this . test . module . registerHook ( 'test_hook' , ( ) => { } ) ;
134
- await sleep ( 0 ) ;
135
- const requestId = this . test . getLatestSent ( ) . requestId ;
136
- this . test . conn . sendResponse ( {
137
- requestId,
138
- type : 6 ,
139
- } ) ;
140
-
141
- return expect ( p ) . to . eventually . equal ( true ) ;
142
- } ) ;
143
-
144
- it ( 'hookTriggered' , async function ( ) {
145
- const fn = sinon . fake ( ) ;
146
- const p = this . test . module . registerHook ( 'test_hook' , fn ) ;
147
- await sleep ( 0 ) ;
148
- this . test . conn . sendResponse ( {
149
- requestId : '12345' ,
150
- type : 8 ,
151
- hook : 'test_hook'
152
- } ) ;
153
- // await sleep(0);
154
- assert ( fn . calledOnce ) ;
155
- } ) ;
156
-
157
- it ( 'functionCall' , async function ( ) {
158
- const fn = sinon . fake ( ) ;
159
- const p = this . test . module . declareFunction ( 'test_fn' , fn ) ;
160
- await sleep ( 0 ) ;
161
-
162
- this . test . conn . sendResponse ( {
163
- requestId : '12345' ,
164
- type : 3 ,
165
- function : 'test_fn'
166
- } ) ;
167
-
168
- assert ( fn . calledOnce ) ;
169
-
170
- this . test . conn . sendResponse ( {
171
- requestId : '12345' ,
172
- type : 3 ,
173
- function : 'test_fn' ,
174
- arguments : { a : 1 , b : 2 }
175
- } ) ;
176
-
177
- expect ( fn . getCall ( 1 ) . args [ 0 ] ) . to . deep . equal ( { a : 1 , b : 2 } ) ;
178
- } ) ;
179
-
180
- it ( 'functionResponse' , async function ( ) {
181
- const p = this . test . module . callFunction ( 'module.test_fn' ) ;
182
- await sleep ( 0 ) ;
183
- const requestId = this . test . getLatestSent ( ) . requestId ;
184
-
185
- this . test . conn . sendResponse ( {
186
- requestId,
187
- type : 4 ,
188
- data : {
189
- a :1 ,
120
+ makeConnectionTests (
121
+ 'Test if responses from gotham parsed correctly' ,
122
+ async function ( ) {
123
+ it ( 'declareFunction' , async function ( ) {
124
+ const p = this . test . module . declareFunction ( 'test_fn' , ( ) => { } ) ;
125
+ const requestId = this . test . getLatestSent ( ) . requestId ;
126
+ await sleep ( 0 ) ;
127
+ this . test . conn . sendResponse ( {
128
+ requestId,
129
+ type : 10 ,
130
+ function : 'test_fn'
131
+ } ) ;
132
+ return expect ( p ) . to . eventually . equal ( true ) ;
133
+ } ) ;
134
+ it ( 'hookRegistered' , async function ( ) {
135
+ const p = this . test . module . registerHook ( 'test_hook' , ( ) => { } ) ;
136
+ await sleep ( 0 ) ;
137
+ const requestId = this . test . getLatestSent ( ) . requestId ;
138
+ this . test . conn . sendResponse ( {
139
+ requestId,
140
+ type : 6 ,
141
+ } ) ;
142
+
143
+ return expect ( p ) . to . eventually . equal ( true ) ;
144
+ } ) ;
145
+
146
+ it ( 'hookTriggered' , async function ( ) {
147
+ const fn = sinon . fake ( ) ;
148
+ const p = this . test . module . registerHook ( 'test_hook' , fn ) ;
149
+ await sleep ( 0 ) ;
150
+ this . test . conn . sendResponse ( {
151
+ requestId : '12345' ,
152
+ type : 8 ,
153
+ hook : 'test_hook'
154
+ } ) ;
155
+ // await sleep(0);
156
+ assert ( fn . calledOnce ) ;
157
+ } ) ;
158
+
159
+ it ( 'functionCall' , async function ( ) {
160
+ const fn = sinon . fake ( ) ;
161
+ const p = this . test . module . declareFunction ( 'test_fn' , fn ) ;
162
+ await sleep ( 0 ) ;
163
+
164
+ this . test . conn . sendResponse ( {
165
+ requestId : '12345' ,
166
+ type : 3 ,
167
+ function : 'test_fn'
168
+ } ) ;
169
+
170
+ assert ( fn . calledOnce ) ;
171
+
172
+ this . test . conn . sendResponse ( {
173
+ requestId : '12345' ,
174
+ type : 3 ,
175
+ function : 'test_fn' ,
176
+ arguments : { a : 1 , b : 2 }
177
+ } ) ;
178
+
179
+ expect ( fn . getCall ( 1 ) . args [ 0 ] ) . to . deep . equal ( { a : 1 , b : 2 } ) ;
180
+ } ) ;
181
+
182
+ it ( 'functionResponse' , async function ( ) {
183
+ const p = this . test . module . callFunction ( 'module.test_fn' ) ;
184
+ await sleep ( 0 ) ;
185
+ const requestId = this . test . getLatestSent ( ) . requestId ;
186
+
187
+ this . test . conn . sendResponse ( {
188
+ requestId,
189
+ type : 4 ,
190
+ data : {
191
+ a : 1 ,
192
+ b : 2
193
+ }
194
+ } ) ;
195
+
196
+ return expect ( p ) . to . eventually . deep . equal ( {
197
+ a : 1 ,
190
198
b : 2
191
- }
192
- } ) ;
193
-
194
- return expect ( p ) . to . eventually . deep . equal ( {
195
- a :1 ,
196
- b :2
199
+ } ) ;
197
200
} ) ;
198
- } ) ;
199
- } ) ;
201
+ }
202
+ ) ;
0 commit comments