mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 17:16:25 +00:00
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import * as httpMock from '../../../test/http-mock';
|
|
import { setBaseUrl } from '../../util/http/bitbucket';
|
|
import * as utils from './utils';
|
|
|
|
const range = (count: number) => [...Array(count).keys()];
|
|
|
|
const baseUrl = 'https://api.bitbucket.org';
|
|
|
|
describe('accumulateValues()', () => {
|
|
it('paginates', async () => {
|
|
httpMock.reset();
|
|
httpMock.setup();
|
|
setBaseUrl(baseUrl);
|
|
|
|
httpMock
|
|
.scope(baseUrl)
|
|
.get('/some-url?pagelen=10')
|
|
.reply(200, {
|
|
values: range(10),
|
|
next:
|
|
'https://api.bitbucket.org/2.0/repositories/?pagelen=10&after=9&role=contributor',
|
|
})
|
|
.get('/2.0/repositories/?pagelen=10&after=9&role=contributor')
|
|
.reply(200, {
|
|
values: range(10),
|
|
next:
|
|
'https://api.bitbucket.org/2.0/repositories/?pagelen=10&after=19&role=contributor',
|
|
})
|
|
.get('/2.0/repositories/?pagelen=10&after=19&role=contributor')
|
|
.reply(200, {
|
|
values: range(5),
|
|
});
|
|
|
|
const res = await utils.accumulateValues('some-url', 'get', null, 10);
|
|
expect(res).toHaveLength(25);
|
|
expect(httpMock.getTrace()).toHaveLength(3);
|
|
expect(httpMock.getTrace()).toMatchSnapshot();
|
|
});
|
|
});
|