Skip to content

Commit

Permalink
test: use nock for preset tests (#6449)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Jun 7, 2020
1 parent 0318efe commit 4d7c109
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 143 deletions.
189 changes: 188 additions & 1 deletion lib/config/presets/github/__snapshots__/index.spec.ts.snap
@@ -1,7 +1,194 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`config/presets/github fetchJSONFile() returns JSON 1`] = `
exports[`config/presets/github/index fetchJSONFile() returns JSON 1`] = `
Object {
"from": "api",
}
`;

exports[`config/presets/github/index fetchJSONFile() returns JSON 2`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/some-filename.json",
},
]
`;

exports[`config/presets/github/index getPreset() should query preset within the file 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/somefile.json",
},
]
`;

exports[`config/presets/github/index getPreset() should query subpreset 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/somefile.json",
},
]
`;

exports[`config/presets/github/index getPreset() should return custom.json 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.machine-man-preview+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/custom.json",
},
]
`;

exports[`config/presets/github/index getPreset() should return default.json 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/default.json",
},
]
`;

exports[`config/presets/github/index getPreset() should return undefined 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.machine-man-preview+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/somefile.json",
},
]
`;

exports[`config/presets/github/index getPreset() throws if fails to parse 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/default.json",
},
]
`;

exports[`config/presets/github/index getPreset() throws if no content 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/default.json",
},
]
`;

exports[`config/presets/github/index getPreset() tries default then renovate 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/default.json",
},
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/renovate.json",
},
]
`;

exports[`config/presets/github/index getPresetFromEndpoint() uses custom endpoint 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.example.org",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.example.org/repos/some/repo/contents/default.json",
},
]
`;

exports[`config/presets/github/index getPresetFromEndpoint() uses default endpoint 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/vnd.github.v3+json",
"accept-encoding": "gzip, deflate",
"authorization": "token abc",
"host": "api.github.com",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://api.github.com/repos/some/repo/contents/default.json",
},
]
`;

0 comments on commit 4d7c109

Please sign in to comment.