diff --git a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap index d1ed188aca58b1d86ebbf7c35b8f478a7dac3d50..298f4f4de9cfc85ae409301aa7e1694029ab0391 100644 --- a/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap +++ b/lib/workers/pr/changelog/__snapshots__/release-notes.spec.ts.snap @@ -1,45 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`workers/pr/changelog/release-notes addReleaseNotes() returns ChangeLogResult 1`] = ` -Object { - "a": 1, - "hasReleaseNotes": false, - "project": Object { - "repository": "https://github.com/nodeca/js-yaml", - "type": "github", - }, - "versions": Array [ - Object { - "compare": Object { - "url": "", - }, - "releaseNotes": null, - "version": "3.10.0", - }, - ], -} -`; - -exports[`workers/pr/changelog/release-notes addReleaseNotes() returns ChangeLogResult without release notes 1`] = ` -Object { - "a": 1, - "hasReleaseNotes": false, - "project": Object { - "repository": "https://gitlab.com/gitlab-org/gitter/webapp/", - "type": "gitlab", - }, - "versions": Array [ - Object { - "compare": Object { - "url": "", - }, - "releaseNotes": null, - "version": "20.26.0", - }, - ], -} -`; - exports[`workers/pr/changelog/release-notes getReleaseList() should return release list for github repo 1`] = ` Array [ Object { diff --git a/lib/workers/pr/changelog/release-notes.spec.ts b/lib/workers/pr/changelog/release-notes.spec.ts index bf1889e1787bebbff4debe69fc35fa19255bcb2c..209a741fd1b9168e4479e8db4647d1d8f10c46fa 100644 --- a/lib/workers/pr/changelog/release-notes.spec.ts +++ b/lib/workers/pr/changelog/release-notes.spec.ts @@ -102,8 +102,23 @@ describe('workers/pr/changelog/release-notes', () => { }, versions: [{ version: '3.10.0', compare: { url: '' } }], }; - // FIXME: explicit assert condition - expect(await addReleaseNotes(input as never)).toMatchSnapshot(); + expect(await addReleaseNotes(input as never)).toEqual({ + a: 1, + hasReleaseNotes: false, + project: { + repository: 'https://github.com/nodeca/js-yaml', + type: 'github', + }, + versions: [ + { + compare: { + url: '', + }, + releaseNotes: null, + version: '3.10.0', + }, + ], + }); }); it('returns ChangeLogResult without release notes', async () => { @@ -117,8 +132,23 @@ describe('workers/pr/changelog/release-notes', () => { { version: '20.26.0', compare: { url: '' } } as ChangeLogRelease, ], } as ChangeLogResult; - // FIXME: explicit assert condition - expect(await addReleaseNotes(input)).toMatchSnapshot(); + expect(await addReleaseNotes(input)).toEqual({ + a: 1, + hasReleaseNotes: false, + project: { + repository: 'https://gitlab.com/gitlab-org/gitter/webapp/', + type: 'gitlab', + }, + versions: [ + { + compare: { + url: '', + }, + releaseNotes: null, + version: '20.26.0', + }, + ], + }); }); }); @@ -144,8 +174,19 @@ describe('workers/pr/changelog/release-notes', () => { ...githubProject, repository: 'some/yet-other-repository', }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot([ + { + notesSourceUrl: + 'https://api.github.com/repos/some/yet-other-repository/releases', + tag: 'v1.0.0', + }, + { + body: 'some body #123, [#124](https://github.com/some/yet-other-repository/issues/124)', + notesSourceUrl: + 'https://api.github.com/repos/some/yet-other-repository/releases', + tag: 'v1.0.1', + }, + ]); expect(httpMock.getTrace()).toMatchSnapshot(); }); @@ -166,8 +207,20 @@ describe('workers/pr/changelog/release-notes', () => { ...gitlabProject, repository: 'some/yet-other-repository', }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot([ + { + notesSourceUrl: + 'https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases', + tag: 'v1.0.0', + url: 'https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases/v1.0.0', + }, + { + notesSourceUrl: + 'https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases', + tag: 'v1.0.1', + url: 'https://gitlab.com/api/v4/projects/some%2fyet-other-repository/releases/v1.0.1', + }, + ]); expect(httpMock.getTrace()).toMatchSnapshot(); }); @@ -191,8 +244,20 @@ describe('workers/pr/changelog/release-notes', () => { apiBaseUrl: 'https://my.custom.domain/api/v4/', baseUrl: 'https://my.custom.domain/', }); - // FIXME: explicit assert condition - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot([ + { + notesSourceUrl: + 'https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases', + tag: 'v1.0.0', + url: 'https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases/v1.0.0', + }, + { + notesSourceUrl: + 'https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases', + tag: 'v1.0.1', + url: 'https://my.custom.domain/api/v4/projects/some%2fyet-other-repository/releases/v1.0.1', + }, + ]); expect(httpMock.getTrace()).toMatchSnapshot(); }); }); @@ -384,9 +449,11 @@ describe('workers/pr/changelog/release-notes', () => { }, '1.6.9' ); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/angular/angular.js/blob/HEAD/CHANGELOG.md', + url: 'https://github.com/angular/angular.js/blob/HEAD/CHANGELOG.md#169-fiery-basilisk-2018-02-02', + }); expect(httpMock.getTrace()).toMatchSnapshot(); }); @@ -409,9 +476,11 @@ describe('workers/pr/changelog/release-notes', () => { '20.26.0' ); expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://gitlab.com/gitlab-org/gitter/webapp/blob/HEAD/CHANGELOG.md', + url: 'https://gitlab.com/gitlab-org/gitter/webapp/blob/HEAD/CHANGELOG.md#20260---2020-05-18', + }); }); it('parses self hosted gitlab', async () => { @@ -435,9 +504,11 @@ describe('workers/pr/changelog/release-notes', () => { '20.26.0' ); expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://my.custom.domain/gitlab-org/gitter/webapp/blob/HEAD/CHANGELOG.md', + url: 'https://my.custom.domain/gitlab-org/gitter/webapp/blob/HEAD/CHANGELOG.md#20260---2020-05-18', + }); }); it('parses jest', async () => { @@ -459,9 +530,11 @@ describe('workers/pr/changelog/release-notes', () => { '22.0.0' ); expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/facebook/jest/blob/HEAD/CHANGELOG.md', + url: 'https://github.com/facebook/jest/blob/HEAD/CHANGELOG.md#jest-2200', + }); }); it('handles github sourceDirectory', async () => { @@ -489,9 +562,11 @@ describe('workers/pr/changelog/release-notes', () => { '3.10.0' ); expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/nodeca/js-yaml/blob/HEAD/packages/foo/CHANGELOG.md', + url: 'https://github.com/nodeca/js-yaml/blob/HEAD/packages/foo/CHANGELOG.md#3100--2017-09-10', + }); }); it('parses js-yaml', async () => { @@ -513,9 +588,11 @@ describe('workers/pr/changelog/release-notes', () => { '3.10.0' ); expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/nodeca/js-yaml/blob/HEAD/CHANGELOG.md', + url: 'https://github.com/nodeca/js-yaml/blob/HEAD/CHANGELOG.md#3100--2017-09-10', + }); }); it('ignores invalid', async () => { @@ -551,9 +628,11 @@ describe('workers/pr/changelog/release-notes', () => { ); versionOneNotes = res; expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md', + url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1530-httpswwwgithubcomyargsyargscomparev1520v1530-2020-03-08', + }); }); it('parses yargs 15.2.0', async () => { @@ -576,9 +655,11 @@ describe('workers/pr/changelog/release-notes', () => { ); versionTwoNotes = res; expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md', + url: 'https://github.com/yargs/yargs/blob/HEAD/CHANGELOG.md#1520-httpswwwgithubcomyargsyargscomparev1510v1520-2020-03-01', + }); }); it('parses adapter-utils 4.33.0', async () => { @@ -601,9 +682,11 @@ describe('workers/pr/changelog/release-notes', () => { ); versionTwoNotes = res; expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://gitlab.com/itentialopensource/adapter-utils/blob/HEAD/CHANGELOG.md', + url: 'https://gitlab.com/itentialopensource/adapter-utils/blob/HEAD/CHANGELOG.md#4330-05-15-2020', + }); }); it('handles gitlab sourceDirectory', async () => { @@ -632,9 +715,11 @@ describe('workers/pr/changelog/release-notes', () => { ); versionTwoNotes = res; expect(httpMock.getTrace()).toMatchSnapshot(); - // FIXME: explicit assert condition - expect(res).not.toBeNull(); - expect(res).toMatchSnapshot(); + expect(res).toMatchSnapshot({ + notesSourceUrl: + 'https://gitlab.com/itentialopensource/adapter-utils/blob/HEAD/packages/foo/CHANGELOG.md', + url: 'https://gitlab.com/itentialopensource/adapter-utils/blob/HEAD/packages/foo/CHANGELOG.md#4330-05-15-2020', + }); }); it('isUrl', () => {