mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
38 lines
903 B
JavaScript
38 lines
903 B
JavaScript
|
describe('platform/gl-got-wrapper', () => {
|
||
|
let get;
|
||
|
let got;
|
||
|
let endpoints;
|
||
|
beforeEach(() => {
|
||
|
// reset module
|
||
|
jest.resetAllMocks();
|
||
|
jest.mock('got');
|
||
|
got = require('got');
|
||
|
endpoints = require('../../../lib/util/endpoints');
|
||
|
get = require('../../../lib/platform/bitbucket/bb-got-wrapper');
|
||
|
|
||
|
// clean up endpoints
|
||
|
endpoints.clear();
|
||
|
endpoints.update({
|
||
|
platform: 'bitbucket',
|
||
|
token: 'token',
|
||
|
});
|
||
|
});
|
||
|
it('posts', async () => {
|
||
|
const body = ['a', 'b'];
|
||
|
got.mockImplementationOnce(() => ({
|
||
|
body,
|
||
|
}));
|
||
|
const res = await get.post('some-url');
|
||
|
expect(res.body).toEqual(body);
|
||
|
});
|
||
|
it('returns cached', async () => {
|
||
|
get.reset();
|
||
|
got.mockReturnValueOnce({
|
||
|
body: {},
|
||
|
});
|
||
|
const res1 = await get('projects/foo');
|
||
|
const res2 = await get('projects/foo');
|
||
|
expect(res1).toEqual(res2);
|
||
|
});
|
||
|
});
|