/
index.spec.ts
56 lines (54 loc) · 1.56 KB
/
index.spec.ts
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { getPkgReleases } from '..';
import * as httpMock from '../../../test/httpMock';
import { id as datasource } from '.';
describe('datasource/gitlab-tags', () => {
beforeEach(() => {
httpMock.reset();
httpMock.setup();
});
describe('getReleases', () => {
it('returns tags', async () => {
const body = [
{
name: 'v1.0.0',
commit: {
created_at: '2020-03-04T12:01:37.000-06:00',
},
},
{
name: 'v1.1.0',
commit: {},
},
{
name: 'v1.1.1',
},
];
httpMock
.scope('https://gitlab.company.com')
.get('/api/v4/api/v4/projects/some%2Fdep2/repository/tags?per_page=100')
.reply(200, body);
const res = await getPkgReleases({
datasource,
registryUrls: ['https://gitlab.company.com/api/v4/'],
depName: 'some/dep2',
});
expect(res).toMatchSnapshot();
expect(res.releases).toHaveLength(3);
expect(httpMock.getTrace()).toMatchSnapshot();
});
it('returns tags with default registry', async () => {
const body = [{ name: 'v1.0.0' }, { name: 'v1.1.0' }];
httpMock
.scope('https://gitlab.com')
.get('/api/v4/projects/some%2Fdep2/repository/tags?per_page=100')
.reply(200, body);
const res = await getPkgReleases({
datasource,
depName: 'some/dep2',
});
expect(res).toMatchSnapshot();
expect(res.releases).toHaveLength(2);
expect(httpMock.getTrace()).toMatchSnapshot();
});
});
});