diff --git a/lib/datasource/__snapshots__/index.spec.ts.snap b/lib/datasource/__snapshots__/index.spec.ts.snap index d554bca3cfef1bf9abf7f53659118eb03e583fd9..269e3ed3267ddebcc0565ed303e44a124baee401 100644 --- a/lib/datasource/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/__snapshots__/index.spec.ts.snap @@ -22,20 +22,3 @@ Object { "sourceUrl": "https://github.com/nodejs/node", } `; - -exports[`datasource/index merges registries and returns success 1`] = ` -Object { - "releases": Array [ - Object { - "registryUrl": "https://reg1.com", - "version": "1.0.0", - }, - Object { - "registryUrl": "https://reg1.com", - "version": "1.1.0", - }, - ], -} -`; - -exports[`datasource/index warns if multiple registryUrls for registryStrategy=first 1`] = `null`; diff --git a/lib/datasource/index.spec.ts b/lib/datasource/index.spec.ts index 1247412c69044456c6cf58eb6db734be33ad9096..af0a1c4b42039a2d7cca7d2b619ab3d23077e129 100644 --- a/lib/datasource/index.spec.ts +++ b/lib/datasource/index.spec.ts @@ -116,10 +116,10 @@ describe(getName(), () => { datasource: datasourceNpm.id, depName: 'react-native', }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); - expect(res.changelogUrl).toBeDefined(); - expect(res.sourceUrl).toBeDefined(); + expect(res).toMatchSnapshot({ + changelogUrl: + 'https://github.com/react-native-community/react-native-releases/blob/master/CHANGELOG.md', + }); }); it('applies extractVersion', async () => { npmDatasource.getReleases.mockResolvedValue({ @@ -146,9 +146,9 @@ describe(getName(), () => { datasource: datasourceNpm.id, depName: 'node', }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); - expect(res.sourceUrl).toBeDefined(); + expect(res).toMatchSnapshot({ + sourceUrl: 'https://github.com/nodejs/node', + }); }); it('ignores and warns for registryUrls', async () => { await datasource.getPkgReleases({ @@ -165,8 +165,7 @@ describe(getName(), () => { depName: 'something', registryUrls: ['https://docker.com', 'https://docker.io'], }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); + expect(res).toBeNull(); }); it('hunts registries and returns success', async () => { packagistDatasource.getReleases.mockResolvedValueOnce(null); @@ -231,9 +230,18 @@ describe(getName(), () => { depName: 'something', registryUrls: ['https://reg1.com', 'https://reg2.io'], }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); - expect(res.releases).toHaveLength(2); + expect(res).toEqual({ + releases: [ + { + registryUrl: 'https://reg1.com', + version: '1.0.0', + }, + { + registryUrl: 'https://reg1.com', + version: '1.1.0', + }, + ], + }); }); it('merges registries and aborts on ExternalHostError', async () => { mavenDatasource.getReleases.mockImplementationOnce(() => { diff --git a/lib/datasource/metadata.spec.ts b/lib/datasource/metadata.spec.ts index e17b35feccea62223a94ff85c3d724190abf2ccd..eb27c5e7a7ebf4d75b7ba0d197dd23f79fa59999 100644 --- a/lib/datasource/metadata.spec.ts +++ b/lib/datasource/metadata.spec.ts @@ -3,6 +3,7 @@ import * as datasourceMaven from './maven'; import { addMetaData } from './metadata'; import * as datasourceNpm from './npm'; import { PypiDatasource } from './pypi'; +import type { ReleaseResult } from './types'; describe(getName(), () => { it('Should do nothing if dep is not specified', () => { @@ -10,7 +11,7 @@ describe(getName(), () => { }); it('Should handle manualChangelogUrls', () => { - const dep = { + const dep: ReleaseResult = { releases: [ { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, { @@ -26,12 +27,14 @@ describe(getName(), () => { const lookupName = 'django'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + changelogUrl: + 'https://github.com/django/django/tree/master/docs/releases', + }); }); it('Should handle manualSourceUrls', () => { - const dep = { + const dep: ReleaseResult = { releases: [ { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, { @@ -47,12 +50,13 @@ describe(getName(), () => { const lookupName = 'mkdocs'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://github.com/mkdocs/mkdocs', + }); }); it('Should handle parsing of sourceUrls correctly', () => { - const dep = { + const dep: ReleaseResult = { sourceUrl: 'https://github.com/carltongibson/django-filter/tree/master', releases: [ { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, @@ -68,12 +72,13 @@ describe(getName(), () => { const lookupName = 'django-filter'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://github.com/carltongibson/django-filter', + }); }); it('Should handle parsing of sourceUrls correctly for GitLab also', () => { - const dep = { + const dep: ReleaseResult = { sourceUrl: 'https://gitlab.com/meno/dropzone/tree/master', releases: [ { version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' }, @@ -87,8 +92,9 @@ describe(getName(), () => { const lookupName = 'dropzone'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://gitlab.com/meno/dropzone', + }); }); it('Should handle failed parsing of sourceUrls for GitLab', () => { const dep = { @@ -105,8 +111,9 @@ describe(getName(), () => { const lookupName = 'dropzone'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://gitlab-nope', + }); }); it('Should handle failed parsing of sourceUrls for other', () => { const dep = { @@ -123,8 +130,9 @@ describe(getName(), () => { const lookupName = 'dropzone'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition - expect(dep).toMatchSnapshot(); + expect(dep).toMatchSnapshot({ + sourceUrl: 'https://nope-nope-nope', + }); }); it('Should handle non-url', () => { const dep = { @@ -141,7 +149,7 @@ describe(getName(), () => { const lookupName = 'dropzone'; addMetaData(dep, datasource, lookupName); - // FIXME: explicit assert condition + expect(dep).not.toContainKey('sourceUrl'); expect(dep).toMatchSnapshot(); });