@@ -15,7 +15,7 @@ makeConnectionTests('Initalize Tests', function () {
15
15
await sleep ( 0 ) ;
16
16
const message = this . test . getLatestSent ( ) ;
17
17
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
18
- type : 'moduleRegistration' ,
18
+ type : 1 ,
19
19
moduleId : 'test-module' ,
20
20
version : '1.0.0' ,
21
21
dependencies : { }
@@ -30,7 +30,7 @@ makeConnectionTests('Initalize Tests', function () {
30
30
await sleep ( 0 ) ;
31
31
const message = this . test . getLatestSent ( ) ;
32
32
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
33
- type : 'moduleRegistration' ,
33
+ type : 1 ,
34
34
moduleId : 'test-module' ,
35
35
version : '1.0.0' ,
36
36
dependencies : {
@@ -40,31 +40,21 @@ makeConnectionTests('Initalize Tests', function () {
40
40
} ) ;
41
41
} ) ;
42
42
43
- it ( 'Does not allow to send other request without initializing' , async function ( ) {
44
- await expect (
45
- this . test . module . declareFunction ( 'test' , ( ) => { } )
46
- ) . to . be . rejectedWith ( Error ) ;
47
- await expect (
48
- this . test . module . callFunction ( 'test' , { } )
49
- ) . to . be . rejectedWith ( Error ) ;
50
- await expect (
51
- this . test . module . registerHook ( 'test' , ( ) => { } )
52
- ) . to . be . rejectedWith ( Error ) ;
53
- await expect (
54
- this . test . module . triggerHook ( 'test' )
55
- ) . to . be . rejectedWith ( Error ) ;
56
- } ) ;
57
-
58
43
it ( 'Initialize resolves correctly/Cannot initalize twice' , async function ( ) {
59
44
const p = this . test . module . initialize ( 'test-module1' , '1.0.0' , { } ) ;
60
45
await sleep ( 0 ) ;
61
46
const requestId = this . test . getLatestSent ( ) . requestId ;
62
47
this . test . conn . sendResponse ( {
63
48
requestId,
64
- type : 'moduleRegistered'
49
+ type : 2 ,
50
+ } ) ;
51
+ this . test . conn . sendResponse ( {
52
+ requestId : '123' ,
53
+ hook : "gotham.activated" ,
54
+ type : 8
65
55
} ) ;
66
56
expect ( p ) . to . eventually . equal ( true ) ;
67
- return await expect (
57
+ return expect (
68
58
this . test . module . initialize ( 'test-module2' , '1.0.0' , { } )
69
59
) . to . be . rejectedWith ( Error ) ;
70
60
} ) ;
@@ -76,7 +66,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
76
66
const message = this . test . getLatestSent ( ) ;
77
67
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
78
68
function : "test_fn" ,
79
- type : "declareFunction"
69
+ type : 9
80
70
} ) ;
81
71
} ) ;
82
72
@@ -86,7 +76,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
86
76
const message = this . test . getLatestSent ( ) ;
87
77
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
88
78
function : "module.test_fn" ,
89
- type : "functionCall" ,
79
+ type : 3 ,
90
80
arguments : { }
91
81
} ) ;
92
82
} ) ;
@@ -99,7 +89,7 @@ makeConnectionTests('Test if requests constructed correctly', function () {
99
89
const message = this . test . getLatestSent ( ) ;
100
90
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
101
91
function : "module.test_fn" ,
102
- type : "functionCall" ,
92
+ type : 3 ,
103
93
arguments : {
104
94
a : 1 ,
105
95
b : 2
@@ -112,16 +102,16 @@ makeConnectionTests('Test if requests constructed correctly', function () {
112
102
const message = this . test . getLatestSent ( ) ;
113
103
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
114
104
hook : "test_hook" ,
115
- type : "registerHook" ,
105
+ type : 5 ,
116
106
} ) ;
117
107
} ) ;
118
108
119
109
it ( 'triggerHook' , function ( ) {
120
110
this . test . module . triggerHook ( 'test_hook' ) ;
121
111
const message = this . test . getLatestSent ( ) ;
122
112
expect ( message ) . excluding ( 'requestId' ) . to . deep . equal ( {
123
- type : "triggerHook" ,
124
- hook : ' test_hook'
113
+ type : 7 ,
114
+ hook : " test_hook" ,
125
115
} ) ;
126
116
} ) ;
127
117
} ) ;
@@ -134,7 +124,7 @@ makeConnectionTests('Test if responses from gotham parsed correctly', async func
134
124
await sleep ( 0 ) ;
135
125
this . test . conn . sendResponse ( {
136
126
requestId,
137
- type : 'functionDeclared' ,
127
+ type : 10 ,
138
128
function : 'test_fn'
139
129
} ) ;
140
130
return expect ( p ) . to . eventually . equal ( true ) ;
@@ -145,7 +135,7 @@ makeConnectionTests('Test if responses from gotham parsed correctly', async func
145
135
const requestId = this . test . getLatestSent ( ) . requestId ;
146
136
this . test . conn . sendResponse ( {
147
137
requestId,
148
- type : 'hookRegistered' ,
138
+ type : 6 ,
149
139
} ) ;
150
140
151
141
return expect ( p ) . to . eventually . equal ( true ) ;
@@ -157,7 +147,7 @@ makeConnectionTests('Test if responses from gotham parsed correctly', async func
157
147
await sleep ( 0 ) ;
158
148
this . test . conn . sendResponse ( {
159
149
requestId : '12345' ,
160
- type : 'hookTriggered' ,
150
+ type : 8 ,
161
151
hook : 'test_hook'
162
152
} ) ;
163
153
// await sleep(0);
@@ -171,15 +161,15 @@ makeConnectionTests('Test if responses from gotham parsed correctly', async func
171
161
172
162
this . test . conn . sendResponse ( {
173
163
requestId : '12345' ,
174
- type : 'functionCall' ,
164
+ type : 3 ,
175
165
function : 'test_fn'
176
166
} ) ;
177
167
178
168
assert ( fn . calledOnce ) ;
179
169
180
170
this . test . conn . sendResponse ( {
181
171
requestId : '12345' ,
182
- type : 'functionCall' ,
172
+ type : 3 ,
183
173
function : 'test_fn' ,
184
174
arguments : { a : 1 , b : 2 }
185
175
} ) ;
@@ -194,7 +184,7 @@ makeConnectionTests('Test if responses from gotham parsed correctly', async func
194
184
195
185
this . test . conn . sendResponse ( {
196
186
requestId,
197
- type : 'functionResponse' ,
187
+ type : 4 ,
198
188
data : {
199
189
a :1 ,
200
190
b : 2
0 commit comments