-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreateNewVersion.test.js
38 lines (35 loc) · 1.29 KB
/
createNewVersion.test.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
32
33
34
35
36
37
const axios = require('axios');
const {getAxiosConfig} = require('./axiosUtils');
const createNewVersion = require('./createNewVersion')
const {POSTMAN_API_BASE_URL} = require('./constants');
jest.mock('axios');
jest.mock('./axiosUtils', () => {
return {
getAxiosConfig: jest.fn().mockReturnValue({}),
};
});
const axiosPost = axios.post;
describe('test updateSchemaFile', () => {
test('calls the Postman API with the proper payload', async () => {
axiosPost.mockResolvedValue({status: 200, data: {id: "CREATED_ID"}});
const versionCreated = await createNewVersion('API_KEY', 'API_ID', 'SCHEMA_ID', '1.0.0', 'First release');
expect(axiosPost).toHaveBeenCalledTimes(1);
expect(getAxiosConfig).toHaveBeenCalledTimes(1);
expect(getAxiosConfig).toHaveBeenCalledWith('API_KEY');
expect(axiosPost).toHaveBeenCalledWith(
`${POSTMAN_API_BASE_URL}/apis/API_ID/versions`,
{
'name': '1.0.0',
'releaseNotes': 'First release',
'collections': [],
'schemas': [
{
'id': 'SCHEMA_ID'
}
]
},
{},
);
expect(versionCreated).toEqual("CREATED_ID")
});
});