Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: replace as assertions #20527

25 changes: 10 additions & 15 deletions lib/workers/repository/update/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1597,15 +1597,14 @@ describe('workers/repository/update/branch/index', () => {
fileFilters: ['modified_file', 'deleted_file'],
},
upgrades: [
{
...getConfig(),
partial<BranchUpgradeConfig>({
depName: 'some-dep-name',
postUpgradeTasks: {
executionMode: 'update',
commands: ['echo {{{versioning}}}', 'disallowed task'],
fileFilters: ['modified_file', 'deleted_file'],
},
} as BranchUpgradeConfig,
}),
],
} as BranchConfig;
const result = await branchWorker.processBranch(inconfig);
Expand Down Expand Up @@ -1705,9 +1704,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
upgrades: [
upgrades: partial<BranchUpgradeConfig>([
{
...getConfig(),
depName: 'some-dep-name-1',
postUpgradeTasks: {
executionMode: 'update',
Expand All @@ -1719,9 +1717,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
} as BranchUpgradeConfig,
},
{
...getConfig(),
depName: 'some-dep-name-2',
postUpgradeTasks: {
executionMode: 'update',
Expand All @@ -1733,8 +1730,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
} as BranchUpgradeConfig,
],
},
]),
};

const result = await branchWorker.processBranch(inconfig);
Expand Down Expand Up @@ -1856,9 +1853,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
upgrades: [
upgrades: partial<BranchUpgradeConfig>([
{
...getConfig(),
depName: 'some-dep-name-1',
postUpgradeTasks: {
executionMode: 'branch',
Expand All @@ -1870,9 +1866,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
} as BranchUpgradeConfig,
},
{
...getConfig(),
depName: 'some-dep-name-2',
postUpgradeTasks: {
executionMode: 'branch',
Expand All @@ -1884,8 +1879,8 @@ describe('workers/repository/update/branch/index', () => {
'modified_then_deleted_file',
],
},
} as BranchUpgradeConfig,
],
},
]),
};

const result = await branchWorker.processBranch(inconfig);
Expand Down
69 changes: 37 additions & 32 deletions lib/workers/repository/update/pr/changelog/release-notes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
it('returns input if invalid', async () => {
const input = { a: 1 };
expect(
await addReleaseNotes(input as never, {} as BranchUpgradeConfig)
await addReleaseNotes(input as never, partial<BranchUpgradeConfig>({}))
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
).toEqual(input);
expect(await addReleaseNotes(null, {} as BranchUpgradeConfig)).toBeNull();
expect(
await addReleaseNotes({ versions: [] }, {} as BranchUpgradeConfig)
await addReleaseNotes(null, partial<BranchUpgradeConfig>({}))
).toBeNull();
await addReleaseNotes({ versions: [] }, partial<BranchUpgradeConfig>({}))
).toStrictEqual({
versions: [],
});
Expand All @@ -117,7 +118,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
versions: [{ version: '3.10.0', compare: { url: '' } }],
};
expect(
await addReleaseNotes(input as never, {} as BranchUpgradeConfig)
await addReleaseNotes(input as never, partial<BranchUpgradeConfig>({}))
).toEqual({
a: 1,
hasReleaseNotes: false,
Expand Down Expand Up @@ -151,7 +152,9 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
}),
],
} as ChangeLogResult;
expect(await addReleaseNotes(input, {} as BranchUpgradeConfig)).toEqual({
expect(
await addReleaseNotes(input, partial<BranchUpgradeConfig>({}))
).toEqual({
a: 1,
hasReleaseNotes: false,
project: {
Expand Down Expand Up @@ -328,7 +331,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
version: '1.0.0',
gitRef: '1.0.0',
}),
{} as BranchUpgradeConfig
partial<BranchUpgradeConfig>({})
);
expect(res).toBeNull();
});
Expand Down Expand Up @@ -362,8 +365,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
Expand Down Expand Up @@ -404,8 +407,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: '',
Expand Down Expand Up @@ -447,7 +450,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body\n',
Expand Down Expand Up @@ -488,8 +491,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body\n',
Expand Down Expand Up @@ -530,8 +533,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toBeNull();
});
Expand Down Expand Up @@ -565,8 +568,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
Expand Down Expand Up @@ -609,8 +612,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
Expand Down Expand Up @@ -653,8 +656,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
Expand Down Expand Up @@ -696,8 +699,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
Expand Down Expand Up @@ -734,8 +737,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)',
Expand Down Expand Up @@ -772,7 +775,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)',
Expand Down Expand Up @@ -808,8 +811,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.1',
gitRef: '1.0.1',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
body: 'some body #123, [#124](https://gitlab.com/some/yet-other-repository/issues/124)',
Expand Down Expand Up @@ -875,8 +878,8 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.0',
gitRef: '1.0.0',
}),
{} as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({})
);
expect(res).toEqual({
url: 'correct/url/tag.com',
Expand Down Expand Up @@ -909,8 +912,10 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
partial<ChangeLogRelease>({
version: '1.0.0',
gitRef: '1.0.0',
}),
{ extractVersion: 'app-(?<version>[0-9.]*)' } as BranchUpgradeConfig
}),
partial<BranchUpgradeConfig>({
extractVersion: 'app-(?<version>[0-9.]*)',
})
);
expect(res).toEqual({
url: 'correct/url/tag.com',
Expand Down