Fixed tests and created test case for extractVersion flow

This commit is contained in:
Álvaro Torres Cogollo 2022-06-06 08:35:34 +00:00
parent d0d4c004bf
commit b018a6415a
2 changed files with 32 additions and 0 deletions

View file

@ -621,6 +621,37 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
body: 'some body\n', body: 'some body\n',
}); });
}); });
it('fallback to extractVersion', async () => {
githubReleasesMock.mockResolvedValueOnce([
{
version: `app-1.0.0`,
url: 'correct/url/tag.com',
description: 'some body',
},
] as never);
const res = await getReleaseNotes(
{
...githubProject,
repository: 'some/other-repository',
depName: 'exampleDep',
},
{
version: '1.0.0',
gitRef: '1.0.0',
} as ChangeLogRelease,
{ extractVersion: 'app-(?<version>[0-9.]*)' } as BranchUpgradeConfig
);
expect(res).toEqual({
url: 'correct/url/tag.com',
notesSourceUrl:
'https://api.github.com/repos/some/other-repository/releases',
id: undefined,
tag: 'app-1.0.0',
name: undefined,
body: 'some body\n',
});
});
}); });
describe('getReleaseNotesMd()', () => { describe('getReleaseNotesMd()', () => {

View file

@ -566,6 +566,7 @@ describe('workers/repository/update/pr/index', () => {
const dummyRelease: ChangeLogRelease = { const dummyRelease: ChangeLogRelease = {
version: '', version: '',
gitRef: '',
changes: dummyChanges, changes: dummyChanges,
compare: {}, compare: {},
date: '', date: '',