From 0f12451c5c7f29d56bbcd57cd314f08a0395826a Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Tue, 29 Jan 2019 18:14:06 +0100 Subject: [PATCH] tests: improve datasource coverage --- .../datasource/__snapshots__/github.spec.js.snap | 16 ++++++++++++++++ test/datasource/github.spec.js | 9 +++++++++ test/datasource/index.spec.js | 8 ++++++++ test/datasource/npm/index.spec.js | 3 ++- 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/test/datasource/__snapshots__/github.spec.js.snap b/test/datasource/__snapshots__/github.spec.js.snap index cf25900a7e..8995225ec9 100644 --- a/test/datasource/__snapshots__/github.spec.js.snap +++ b/test/datasource/__snapshots__/github.spec.js.snap @@ -15,3 +15,19 @@ Object { "sourceUrl": "https://github.com/some/dep", } `; + +exports[`datasource/github getPkgReleases returns tags 1`] = ` +Object { + "releases": Array [ + Object { + "gitRef": "v1.0.0", + "version": "v1.0.0", + }, + Object { + "gitRef": "v1.1.0", + "version": "v1.1.0", + }, + ], + "sourceUrl": "https://github.com/some/dep2", +} +`; diff --git a/test/datasource/github.spec.js b/test/datasource/github.spec.js index fdc43995b8..3b249ba5e2 100644 --- a/test/datasource/github.spec.js +++ b/test/datasource/github.spec.js @@ -79,6 +79,15 @@ describe('datasource/github', () => { res.releases.find(release => release.version === 'v1.1.0') ).toBeDefined(); }); + it('returns tags', async () => { + const body = [{ name: 'v1.0.0' }, { name: 'v1.1.0' }]; + ghGot.mockReturnValueOnce({ headers: {}, body }); + const res = await datasource.getPkgReleases({ + purl: 'pkg:github/some/dep2', + }); + expect(res).toMatchSnapshot(); + expect(res.releases).toHaveLength(2); + }); it('returns null for invalid ref', async () => { expect( await datasource.getPkgReleases({ diff --git a/test/datasource/index.spec.js b/test/datasource/index.spec.js index 212a3f25e9..f69d2be0b0 100644 --- a/test/datasource/index.spec.js +++ b/test/datasource/index.spec.js @@ -5,6 +5,14 @@ jest.mock('../../lib/datasource/docker'); jest.mock('../../lib/datasource/npm'); describe('datasource/index', () => { + it('returns if digests are supported', async () => { + expect(await datasource.supportsDigests('pkg:github/some/dep')).toBe(true); + }); + it('returns null for unknown datasource', async () => { + expect( + await datasource.getPkgReleases({ purl: 'pkg:gitbucket/some/dep' }) + ).toBeNull(); + }); it('returns null for invalid purl', async () => { expect( await datasource.getPkgReleases({ purl: 'pkggithub/some/dep' }) diff --git a/test/datasource/npm/index.spec.js b/test/datasource/npm/index.spec.js index 75e98c83a5..288863b3ec 100644 --- a/test/datasource/npm/index.spec.js +++ b/test/datasource/npm/index.spec.js @@ -35,6 +35,7 @@ describe('api/npm', () => { url: 'git://github.com/renovateapp/dummy.git', directory: 'src/a', }, + homepage: 'https://github.com/renovateapp/dummy', 'dist-tags': { latest: '0.0.1', }, @@ -153,7 +154,7 @@ describe('api/npm', () => { }, repository: { type: 'git', - url: 'git://github.com/renovateapp/dummy.git', + url: 'https://github.com/renovateapp/dummy.git', }, 'dist-tags': { latest: '0.0.2', -- GitLab