@mojaloop/ml-testing-toolkit-client-lib 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +502 -0
- package/.dockerignore +10 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +5 -0
- package/Dockerfile +25 -0
- package/LICENSE.md +10 -0
- package/README.md +213 -0
- package/audit-resolve.json +14 -0
- package/bin/cli.js +2 -0
- package/jest.config.js +16 -0
- package/native-app-generation/assets/macos/start.sh +7 -0
- package/native-app-generation/build-native-app.sh +57 -0
- package/package.json +132 -0
- package/src/client.js +49 -0
- package/src/extras/s3-upload.js +69 -0
- package/src/extras/slack-broadcast.js +149 -0
- package/src/modes/monitoring.js +32 -0
- package/src/modes/outbound.js +179 -0
- package/src/modes/testcaseDefinitionReport.js +53 -0
- package/src/objectStore.js +39 -0
- package/src/router.js +110 -0
- package/src/sample-config.json +11 -0
- package/src/utils/file-utils.js +53 -0
- package/src/utils/listeners.js +46 -0
- package/src/utils/logger.js +93 -0
- package/src/utils/report.js +127 -0
- package/src/utils/templateGenerator.js +65 -0
- package/test/lib/mockRequest.js +38 -0
- package/test/lib/mockResponse.js +53 -0
- package/test/unit/client.test.js +36 -0
- package/test/unit/extras/s3-upload.test.js +99 -0
- package/test/unit/extras/slack-broadcast.test.js +125 -0
- package/test/unit/listener.test.js +58 -0
- package/test/unit/logger.test.js +259 -0
- package/test/unit/monitoring-mode.test.js +38 -0
- package/test/unit/outbound-mode.test.js +192 -0
- package/test/unit/report.test.js +258 -0
- package/test/unit/router.test.js +110 -0
- package/test/unit/templateGenerator.test.js +119 -0
- package/test/unit/testcaseDefinitionReport-mode.test.js +72 -0
- package/test/util/testConfig.js +38 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
|
|
20
|
+
* ModusBox
|
|
21
|
+
* Georgi Logodazhki <georgi.logodazhki@modusbox.com> (Original Author)
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
'use strict'
|
|
25
|
+
|
|
26
|
+
const socketIOClient = require('socket.io-client')
|
|
27
|
+
jest.mock('socket.io-client')
|
|
28
|
+
const listeners = require('../../src/utils/listeners')
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
describe('Cli client', () => {
|
|
32
|
+
describe('run listeners', () => {
|
|
33
|
+
it('running the outbound listener should not throw an error', async () => {
|
|
34
|
+
const outbound = require('../../src/modes/outbound')
|
|
35
|
+
jest.spyOn(outbound, 'handleIncomingProgress').mockReturnValueOnce({})
|
|
36
|
+
socketIOClient.mockImplementationOnce(() => {
|
|
37
|
+
return {
|
|
38
|
+
on: (someName, incomingFn) => {}
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
expect(() => {
|
|
42
|
+
listeners.outbound()
|
|
43
|
+
}).not.toThrowError();
|
|
44
|
+
})
|
|
45
|
+
it('running the monitoring listener should not throw an error', async () => {
|
|
46
|
+
const monitoring = require('../../src/modes/monitoring')
|
|
47
|
+
jest.spyOn(monitoring, 'handleIncomingProgress').mockReturnValueOnce({})
|
|
48
|
+
socketIOClient.mockImplementationOnce(() => {
|
|
49
|
+
return {
|
|
50
|
+
on: (someName, incomingFn) => {}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
expect(() => {
|
|
54
|
+
listeners.monitoring()
|
|
55
|
+
}).not.toThrowError();
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
|
|
20
|
+
* ModusBox
|
|
21
|
+
* Georgi Logodazhki <georgi.logodazhki@modusbox.com> (Original Author)
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
'use strict'
|
|
25
|
+
|
|
26
|
+
const logger = require('../../src/utils/logger')
|
|
27
|
+
const objectStore = require('../../src/objectStore')
|
|
28
|
+
const spyConsole = jest.spyOn(console, 'log')
|
|
29
|
+
|
|
30
|
+
jest.mock('../../src/objectStore')
|
|
31
|
+
|
|
32
|
+
const sampleOutboundProgress = {
|
|
33
|
+
"status": "FINISHED",
|
|
34
|
+
"test_cases": [
|
|
35
|
+
{
|
|
36
|
+
"id": 1,
|
|
37
|
+
"name": "P2P Transfer Happy Path",
|
|
38
|
+
"requests": [
|
|
39
|
+
{
|
|
40
|
+
"request": {
|
|
41
|
+
"id": 1,
|
|
42
|
+
"description": "Get party information",
|
|
43
|
+
"apiVersion": {
|
|
44
|
+
"minorVersion": 0,
|
|
45
|
+
"majorVersion": 1,
|
|
46
|
+
"type": "fspiop",
|
|
47
|
+
"asynchronous": true
|
|
48
|
+
},
|
|
49
|
+
"operationPath": "/parties/{Type}/{ID}",
|
|
50
|
+
"method": "get",
|
|
51
|
+
"headers": {
|
|
52
|
+
"Accept": "application/vnd.interoperability.parties+json;version=1.0",
|
|
53
|
+
"Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
|
|
54
|
+
"Date": "Thu, 07 May 2020 10:44:00 GMT",
|
|
55
|
+
"FSPIOP-Source": "testingtoolkitdfsp"
|
|
56
|
+
},
|
|
57
|
+
"params": {
|
|
58
|
+
"Type": "MSISDN",
|
|
59
|
+
"ID": "9876543210"
|
|
60
|
+
},
|
|
61
|
+
"tests": {
|
|
62
|
+
"assertions": [
|
|
63
|
+
{
|
|
64
|
+
"id": 1,
|
|
65
|
+
"description": "Response status to be 202",
|
|
66
|
+
"exec": [
|
|
67
|
+
"expect(response.status).to.equal(202)"
|
|
68
|
+
],
|
|
69
|
+
"resultStatus": {
|
|
70
|
+
"status": "SUCCESS"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": 2,
|
|
75
|
+
"description": "Response statusText be Accepted",
|
|
76
|
+
"exec": [
|
|
77
|
+
"expect(response.statusText).to.equal('Accepted')"
|
|
78
|
+
],
|
|
79
|
+
"resultStatus": {
|
|
80
|
+
"status": "SUCCESS"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"passedAssertionsCount": 2
|
|
85
|
+
},
|
|
86
|
+
"path": "/parties/MSISDN/9876543210"
|
|
87
|
+
},
|
|
88
|
+
"response": {
|
|
89
|
+
"status": 202,
|
|
90
|
+
"statusText": "Accepted",
|
|
91
|
+
"data": ""
|
|
92
|
+
},
|
|
93
|
+
"callback": {
|
|
94
|
+
"headers": {
|
|
95
|
+
"content-type": "application/vnd.interoperability.parties+json;version=1.0",
|
|
96
|
+
"date": "Thu, 07 May 2020 10:44:00 GMT",
|
|
97
|
+
"fspiop-source": "userdfsp",
|
|
98
|
+
"fspiop-destination": "testingtoolkitdfsp",
|
|
99
|
+
"authorization": "Bearer 7718fa9b-be13-3fe7-87f0-a12cf1628168",
|
|
100
|
+
"host": "docker.for.mac.localhost:5000",
|
|
101
|
+
"content-length": "231",
|
|
102
|
+
"connection": "close"
|
|
103
|
+
},
|
|
104
|
+
"body": {
|
|
105
|
+
"party": {
|
|
106
|
+
"partyIdInfo": {
|
|
107
|
+
"partyIdType": "MSISDN",
|
|
108
|
+
"partyIdentifier": "9876543210",
|
|
109
|
+
"fspId": "userdfsp"
|
|
110
|
+
},
|
|
111
|
+
"personalInfo": {
|
|
112
|
+
"complexName": {
|
|
113
|
+
"firstName": "Test",
|
|
114
|
+
"middleName": "Test",
|
|
115
|
+
"lastName": "Test"
|
|
116
|
+
},
|
|
117
|
+
"dateOfBirth": "1970-01-01"
|
|
118
|
+
},
|
|
119
|
+
"name": "Test"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"request": {
|
|
126
|
+
"id": 1,
|
|
127
|
+
"description": "Get party information",
|
|
128
|
+
"apiVersion": {
|
|
129
|
+
"minorVersion": 0,
|
|
130
|
+
"majorVersion": 1,
|
|
131
|
+
"type": "fspiop",
|
|
132
|
+
"asynchronous": true
|
|
133
|
+
},
|
|
134
|
+
"operationPath": "/parties/{Type}/{ID}",
|
|
135
|
+
"method": "get",
|
|
136
|
+
"headers": {
|
|
137
|
+
"Accept": "application/vnd.interoperability.parties+json;version=1.0",
|
|
138
|
+
"Content-Type": "application/vnd.interoperability.parties+json;version=1.0",
|
|
139
|
+
"Date": "Thu, 07 May 2020 10:44:00 GMT",
|
|
140
|
+
"FSPIOP-Source": "testingtoolkitdfsp"
|
|
141
|
+
},
|
|
142
|
+
"params": {
|
|
143
|
+
"Type": "MSISDN",
|
|
144
|
+
"ID": "9876543210"
|
|
145
|
+
},
|
|
146
|
+
"tests": {
|
|
147
|
+
"assertions": [
|
|
148
|
+
{
|
|
149
|
+
"id": 1,
|
|
150
|
+
"description": "Response status to be 202",
|
|
151
|
+
"exec": [
|
|
152
|
+
"expect(response.status).to.equal(202)"
|
|
153
|
+
],
|
|
154
|
+
"resultStatus": {
|
|
155
|
+
"status": "SUCCESS"
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"id": 2,
|
|
160
|
+
"description": "Response statusText be Accepted",
|
|
161
|
+
"exec": [
|
|
162
|
+
"expect(response.statusText).to.equal('Accepted')"
|
|
163
|
+
],
|
|
164
|
+
"resultStatus": {
|
|
165
|
+
"status": "FAILED"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"passedAssertionsCount": 1
|
|
170
|
+
},
|
|
171
|
+
"path": "/parties/MSISDN/9876543210"
|
|
172
|
+
},
|
|
173
|
+
"response": {
|
|
174
|
+
"status": 202,
|
|
175
|
+
"statusText": "Accepted",
|
|
176
|
+
"data": ""
|
|
177
|
+
},
|
|
178
|
+
"callback": {
|
|
179
|
+
"headers": {
|
|
180
|
+
"content-type": "application/vnd.interoperability.parties+json;version=1.0",
|
|
181
|
+
"date": "Thu, 07 May 2020 10:44:00 GMT",
|
|
182
|
+
"fspiop-source": "userdfsp",
|
|
183
|
+
"fspiop-destination": "testingtoolkitdfsp",
|
|
184
|
+
"authorization": "Bearer 7718fa9b-be13-3fe7-87f0-a12cf1628168",
|
|
185
|
+
"host": "docker.for.mac.localhost:5000",
|
|
186
|
+
"content-length": "231",
|
|
187
|
+
"connection": "close"
|
|
188
|
+
},
|
|
189
|
+
"body": {
|
|
190
|
+
"party": {
|
|
191
|
+
"partyIdInfo": {
|
|
192
|
+
"partyIdType": "MSISDN",
|
|
193
|
+
"partyIdentifier": "9876543210",
|
|
194
|
+
"fspId": "userdfsp"
|
|
195
|
+
},
|
|
196
|
+
"personalInfo": {
|
|
197
|
+
"complexName": {
|
|
198
|
+
"firstName": "Test",
|
|
199
|
+
"middleName": "Test",
|
|
200
|
+
"lastName": "Test"
|
|
201
|
+
},
|
|
202
|
+
"dateOfBirth": "1970-01-01"
|
|
203
|
+
},
|
|
204
|
+
"name": "Test"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
"runtimeInformation": {
|
|
213
|
+
"completedTimeISO": "2020-05-07T10:44:01.687Z",
|
|
214
|
+
"startedTime": "Thu, 07 May 2020 10:44:00 GMT",
|
|
215
|
+
"completedTime": "Thu, 07 May 2020 10:44:01 GMT",
|
|
216
|
+
"runDurationMs": 1195,
|
|
217
|
+
"avgResponseTime": "NA"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
describe('Cli client', () => {
|
|
222
|
+
describe('run logger functionality', () => {
|
|
223
|
+
it('when the cli mode is outbound should not throw an error', async () => {
|
|
224
|
+
objectStore.get.mockReturnValueOnce({})
|
|
225
|
+
expect(() => {
|
|
226
|
+
logger.outbound(sampleOutboundProgress)
|
|
227
|
+
}).not.toThrowError()
|
|
228
|
+
})
|
|
229
|
+
it('when extraSummaryInformation is supplied, it should be logged', async () => {
|
|
230
|
+
objectStore.get.mockReturnValueOnce({
|
|
231
|
+
extraSummaryInformation: 'Title:Mocktitle,Summary:MockSummary'
|
|
232
|
+
})
|
|
233
|
+
logger.outbound(sampleOutboundProgress)
|
|
234
|
+
expect(spyConsole).toBeCalled()
|
|
235
|
+
})
|
|
236
|
+
it('when the cli mode is monitoring should not throw an error 1', async () => {
|
|
237
|
+
const sampleMonitoringProgress = {
|
|
238
|
+
"logTime": "Thu, 07 May 2020 10:44:00 GMT",
|
|
239
|
+
"message": "SUCCESS",
|
|
240
|
+
"verbosity": "info",
|
|
241
|
+
"additionalData": {}
|
|
242
|
+
}
|
|
243
|
+
expect(() => {
|
|
244
|
+
logger.monitoring(sampleMonitoringProgress)
|
|
245
|
+
}).not.toThrowError()
|
|
246
|
+
})
|
|
247
|
+
it('when the cli mode is monitoring should not throw an error 2', async () => {
|
|
248
|
+
const sampleMonitoringProgress = {
|
|
249
|
+
"logTime": "Thu, 07 May 2020 10:44:00 GMT",
|
|
250
|
+
"message": "SUCCESS",
|
|
251
|
+
"verbosity": "info",
|
|
252
|
+
"uniqueId": "uniqueId"
|
|
253
|
+
}
|
|
254
|
+
expect(() => {
|
|
255
|
+
logger.monitoring(sampleMonitoringProgress)
|
|
256
|
+
}).not.toThrowError()
|
|
257
|
+
})
|
|
258
|
+
})
|
|
259
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
|
|
20
|
+
* ModusBox
|
|
21
|
+
* Georgi Logodazhki <georgi.logodazhki@modusbox.com> (Original Author)
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
'use strict'
|
|
25
|
+
|
|
26
|
+
const logger = require('../../src/utils/logger')
|
|
27
|
+
const monitoringMode = require('../../src/modes/monitoring')
|
|
28
|
+
|
|
29
|
+
describe('Cli client', () => {
|
|
30
|
+
describe('run monitoring mode', () => {
|
|
31
|
+
it('when the cli mode is monitoring should not throw an error', async () => {
|
|
32
|
+
jest.spyOn(logger, 'monitoring').mockReturnValueOnce({})
|
|
33
|
+
expect(() => {
|
|
34
|
+
monitoringMode.handleIncomingProgress({})
|
|
35
|
+
}).not.toThrowError()
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
})
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/*****
|
|
2
|
+
License
|
|
3
|
+
--------------
|
|
4
|
+
Copyright © 2017 Bill & Melinda Gates Foundation
|
|
5
|
+
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
8
|
+
Contributors
|
|
9
|
+
--------------
|
|
10
|
+
This is the official list of the Mojaloop project contributors for this file.
|
|
11
|
+
Names of the original copyright holders (individuals or organizations)
|
|
12
|
+
should be listed with a '*' in the first column. People who have
|
|
13
|
+
contributed from an organization can be listed under the organization
|
|
14
|
+
that actually holds the copyright for their contributions (see the
|
|
15
|
+
Gates Foundation organization for an example). Those individuals should have
|
|
16
|
+
their names indented and be marked with a '-'. Email address can be added
|
|
17
|
+
optionally within square brackets <email>.
|
|
18
|
+
* Gates Foundation
|
|
19
|
+
|
|
20
|
+
* ModusBox
|
|
21
|
+
* Georgi Logodazhki <georgi.logodazhki@modusbox.com> (Original Author)
|
|
22
|
+
--------------
|
|
23
|
+
******/
|
|
24
|
+
'use strict'
|
|
25
|
+
|
|
26
|
+
const axios = require('axios')
|
|
27
|
+
const spyReport = jest.spyOn(require('../../src/utils/report'), 'outbound')
|
|
28
|
+
const spyLogger = jest.spyOn(require('../../src/utils/logger'), 'outbound')
|
|
29
|
+
const spyExit = jest.spyOn(process, 'exit')
|
|
30
|
+
const spyAxios = jest.spyOn(axios, 'post')
|
|
31
|
+
const spyPromisify = jest.spyOn(require('util'), 'promisify')
|
|
32
|
+
const objectStore = require('../../src/objectStore')
|
|
33
|
+
|
|
34
|
+
const outbound = require('../../src/modes/outbound')
|
|
35
|
+
const spyGenerateTemplate = jest.spyOn(require('../../src/utils/templateGenerator'), 'generateTemplate')
|
|
36
|
+
|
|
37
|
+
describe('Cli client', () => {
|
|
38
|
+
describe('run outbound mode', () => {
|
|
39
|
+
it('when status is FINISHED and assertion passed should not throw an error', async () => {
|
|
40
|
+
const progress = {
|
|
41
|
+
"status": "FINISHED"
|
|
42
|
+
}
|
|
43
|
+
spyReport.mockReturnValueOnce({})
|
|
44
|
+
spyLogger.mockReturnValueOnce(true)
|
|
45
|
+
spyExit.mockReturnValueOnce({})
|
|
46
|
+
expect(() => {
|
|
47
|
+
outbound.handleIncomingProgress(progress)
|
|
48
|
+
}).not.toThrowError()
|
|
49
|
+
})
|
|
50
|
+
it('when status is FINISHED, assertions passed and there is an error should not throw an error', async () => {
|
|
51
|
+
const progress = {
|
|
52
|
+
"status": "FINISHED"
|
|
53
|
+
}
|
|
54
|
+
spyReport.mockImplementationOnce(() => {throw new Error('expected error')})
|
|
55
|
+
spyLogger.mockReturnValueOnce(true)
|
|
56
|
+
spyExit.mockReturnValueOnce({})
|
|
57
|
+
expect(() => {
|
|
58
|
+
outbound.handleIncomingProgress(progress)
|
|
59
|
+
}).not.toThrowError()
|
|
60
|
+
})
|
|
61
|
+
it('when status is FINISHED and assertions failed should not throw an error', async () => {
|
|
62
|
+
const progress = {
|
|
63
|
+
"status": "FINISHED"
|
|
64
|
+
}
|
|
65
|
+
spyReport.mockReturnValueOnce({})
|
|
66
|
+
spyLogger.mockReturnValueOnce(false)
|
|
67
|
+
spyExit.mockReturnValueOnce({})
|
|
68
|
+
expect(() => {
|
|
69
|
+
outbound.handleIncomingProgress(progress)
|
|
70
|
+
}).not.toThrowError()
|
|
71
|
+
})
|
|
72
|
+
it('when status is not FINISHED should not throw an error', async () => {
|
|
73
|
+
const progress = {
|
|
74
|
+
"status": "IN PROGRESS"
|
|
75
|
+
}
|
|
76
|
+
spyExit.mockReturnValueOnce({})
|
|
77
|
+
expect(() => {
|
|
78
|
+
outbound.handleIncomingProgress(progress)
|
|
79
|
+
}).not.toThrowError()
|
|
80
|
+
})
|
|
81
|
+
})
|
|
82
|
+
describe('when status is not FINISHED should not throw an error where there are assertions', () => {
|
|
83
|
+
const progress = {
|
|
84
|
+
"status": "IN PROGRESS",
|
|
85
|
+
requestSent: {
|
|
86
|
+
tests: {
|
|
87
|
+
assertions: [
|
|
88
|
+
{
|
|
89
|
+
id: 1
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 2
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 3 }
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
testResult: {
|
|
100
|
+
results: {
|
|
101
|
+
1: {
|
|
102
|
+
status: 'SUCCESS'
|
|
103
|
+
},
|
|
104
|
+
2: {
|
|
105
|
+
status: 'SKIPPED'
|
|
106
|
+
},
|
|
107
|
+
3: {
|
|
108
|
+
status: 'FAILED'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
it('Without loglevel', async () => {
|
|
114
|
+
const config = {
|
|
115
|
+
inputFiles: "sample-cli.json",
|
|
116
|
+
environmentFile: "sample-environement.json",
|
|
117
|
+
}
|
|
118
|
+
objectStore.set('config', config)
|
|
119
|
+
|
|
120
|
+
spyExit.mockReturnValueOnce({})
|
|
121
|
+
expect(() => {
|
|
122
|
+
outbound.handleIncomingProgress(progress)
|
|
123
|
+
}).not.toThrowError()
|
|
124
|
+
})
|
|
125
|
+
it('With loglevel 1', async () => {
|
|
126
|
+
const config = {
|
|
127
|
+
inputFiles: "sample-cli.json",
|
|
128
|
+
environmentFile: "sample-environement.json",
|
|
129
|
+
logLevel: '1'
|
|
130
|
+
}
|
|
131
|
+
objectStore.set('config', config)
|
|
132
|
+
|
|
133
|
+
spyExit.mockReturnValueOnce({})
|
|
134
|
+
expect(() => {
|
|
135
|
+
outbound.handleIncomingProgress(progress)
|
|
136
|
+
}).not.toThrowError()
|
|
137
|
+
})
|
|
138
|
+
it('With loglevel 2', async () => {
|
|
139
|
+
const config = {
|
|
140
|
+
inputFiles: "sample-cli.json",
|
|
141
|
+
environmentFile: "sample-environement.json",
|
|
142
|
+
logLevel: '2'
|
|
143
|
+
}
|
|
144
|
+
objectStore.set('config', config)
|
|
145
|
+
|
|
146
|
+
spyExit.mockReturnValueOnce({})
|
|
147
|
+
expect(() => {
|
|
148
|
+
outbound.handleIncomingProgress(progress)
|
|
149
|
+
}).not.toThrowError()
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
describe('run sendTemplate', () => {
|
|
153
|
+
it('when generateTemplate is successful should not throw an error', async () => {
|
|
154
|
+
spyPromisify.mockReturnValueOnce(() => {
|
|
155
|
+
return JSON.stringify({
|
|
156
|
+
"inputValues": {}
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
const config = {
|
|
160
|
+
inputFiles: "sample-cli.json",
|
|
161
|
+
environmentFile: "sample-environement.json"
|
|
162
|
+
}
|
|
163
|
+
spyGenerateTemplate.mockResolvedValueOnce({
|
|
164
|
+
"test_cases": [
|
|
165
|
+
{
|
|
166
|
+
"requests": []
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
objectStore.set('config', config)
|
|
171
|
+
|
|
172
|
+
spyAxios.mockResolvedValueOnce({})
|
|
173
|
+
await expect(outbound.sendTemplate()).resolves.toBe(undefined)
|
|
174
|
+
})
|
|
175
|
+
it('when generateTemplate failed should throw an error', async () => {
|
|
176
|
+
spyPromisify.mockReturnValueOnce(() => {
|
|
177
|
+
return JSON.stringify({
|
|
178
|
+
"inputValues": {}
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
const config = {
|
|
182
|
+
inputFiles: "sample-cli.json",
|
|
183
|
+
environmentFile: "sample-environement.json"
|
|
184
|
+
}
|
|
185
|
+
spyGenerateTemplate.mockRejectedValueOnce({})
|
|
186
|
+
objectStore.set('config', config)
|
|
187
|
+
|
|
188
|
+
spyAxios.mockReturnValue({})
|
|
189
|
+
await expect(outbound.sendTemplate()).resolves.toBe(undefined)
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
})
|