forked from codefresh-io/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-setup.js
31 lines (27 loc) · 879 Bytes
/
test-setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const _ = require('lodash');
const request = require('requestretry');
const sdk = require('./lib/logic/sdk');
const { Config } = require('codefresh-sdk');
const openapi = require('./openapi');
jest.mock('./lib/output/Output');
jest.mock('codefresh-sdk/helpers/whoami');
let SDK_CONFIGURED;
global.verifyResponsesReturned = async (responses) => {
const { results } = request.mock;
let returnedResponses = _.map(results, r => r.value);
returnedResponses = await Promise.all(returnedResponses);
expect(returnedResponses).toEqual(responses);
};
/**
* downloads spec one time for all tests
* */
global.configureSdk = async () => {
if (!SDK_CONFIGURED) {
SDK_CONFIGURED = true;
sdk.configure(await Config.load({
url: 'http://not.needed',
apiKey: 'not-needed',
spec: { json: openapi },
}));
}
};