/
azure-got-wrapper.spec.ts
71 lines (59 loc) · 2.21 KB
/
azure-got-wrapper.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { PlatformId } from '../../constants';
import * as _hostRules from '../../util/host-rules';
describe('platform/azure/azure-got-wrapper', () => {
let azure: typeof import('./azure-got-wrapper');
let hostRules: typeof _hostRules;
beforeEach(() => {
// reset module
jest.resetModules();
hostRules = require('../../util/host-rules');
azure = require('./azure-got-wrapper');
});
describe('gitApi', () => {
it('should throw an error if no config found', () => {
expect(azure.gitApi).toThrow('No config found for azure');
expect(azure.coreApi).toThrow('No config found for azure');
expect(azure.policyApi).toThrow('No config found for azure');
});
it('should set personal access token and endpoint', () => {
hostRules.add({
hostType: PlatformId.Azure,
token: '123test',
matchHost: 'https://dev.azure.com/renovate1',
});
azure.setEndpoint('https://dev.azure.com/renovate1');
const res = azure.azureObj();
delete res.rest.client.userAgent;
delete res.vsoClient.restClient.client.userAgent;
// We will track if the lib azure-devops-node-api change
expect(res).toMatchSnapshot();
});
it('should set bearer token and endpoint', () => {
hostRules.add({
hostType: PlatformId.Azure,
token: 'testtoken',
matchHost: 'https://dev.azure.com/renovate2',
});
azure.setEndpoint('https://dev.azure.com/renovate2');
const res = azure.azureObj();
delete res.rest.client.userAgent;
delete res.vsoClient.restClient.client.userAgent;
// We will track if the lib azure-devops-node-api change
expect(res).toMatchSnapshot();
});
it('should set password and endpoint', () => {
hostRules.add({
hostType: PlatformId.Azure,
username: 'user',
password: 'pass',
matchHost: 'https://dev.azure.com/renovate3',
});
azure.setEndpoint('https://dev.azure.com/renovate3');
const res = azure.azureObj();
delete res.rest.client.userAgent;
delete res.vsoClient.restClient.client.userAgent;
// We will track if the lib azure-devops-node-api change
expect(res).toMatchSnapshot();
});
});
});