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

2 changes: 1 addition & 1 deletion lib/modules/platform/default-scm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('modules/platform/default-scm', () => {

it('delegate commitAndPush to util/git', async () => {
git.commitFiles.mockResolvedValueOnce('sha');
await defaultGitScm.commitAndPush(partial<CommitFilesConfig>({}));
await defaultGitScm.commitAndPush(partial<CommitFilesConfig>());
expect(git.commitFiles).toHaveBeenCalledTimes(1);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jest.mock('../../../../util/git');
describe('workers/repository/update/branch/execute-post-upgrade-commands', () => {
describe('postUpgradeCommandsExecutor', () => {
it('handles an artifact which is a directory', async () => {
const commands: BranchUpgradeConfig[] = [
const commands = partial<BranchUpgradeConfig>([
{
manager: 'some-manager',
branchName: 'main',
Expand All @@ -19,7 +19,7 @@ describe('workers/repository/update/branch/execute-post-upgrade-commands', () =>
commands: ['disallowed_command'],
},
},
];
]);
const config: BranchConfig = {
manager: 'some-manager',
updatedPackageFiles: [],
Expand Down
35 changes: 15 additions & 20 deletions lib/workers/repository/update/branch/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('workers/repository/update/branch/index', () => {
branchName: 'renovate/some-branch',
errors: [],
warnings: [],
upgrades: [partial<BranchUpgradeConfig>({ depName: 'some-dep-name' })],
upgrades: partial<BranchUpgradeConfig>([{ depName: 'some-dep-name' }]),
} as BranchConfig;
schedule.isScheduledNow.mockReturnValue(true);
commit.commitFilesToBranch.mockResolvedValue('123test');
Expand Down Expand Up @@ -185,12 +185,12 @@ describe('workers/repository/update/branch/index', () => {
it('skips branch if not stabilityDays not met', async () => {
schedule.isScheduledNow.mockReturnValueOnce(true);
config.prCreation = 'not-pending';
(config.upgrades as Partial<BranchUpgradeConfig>[]) = [
config.upgrades = partial<BranchUpgradeConfig>([
{
releaseTimestamp: '2099-12-31',
stabilityDays: 1,
},
];
]);
const res = await branchWorker.processBranch(config);
expect(res).toEqual({
branchExists: false,
Expand Down Expand Up @@ -221,11 +221,11 @@ describe('workers/repository/update/branch/index', () => {
it('processes branch if minimumConfidence is met', async () => {
schedule.isScheduledNow.mockReturnValueOnce(true);
config.prCreation = 'not-pending';
(config.upgrades as Partial<BranchUpgradeConfig>[]) = [
config.upgrades = partial<BranchUpgradeConfig>([
{
minimumConfidence: 'high',
},
];
]);
mergeConfidence.isActiveConfidenceLevel.mockReturnValue(true);
mergeConfidence.satisfiesConfidenceLevel.mockReturnValueOnce(true);
const res = await branchWorker.processBranch(config);
Expand Down 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
13 changes: 7 additions & 6 deletions lib/workers/repository/update/pr/body/updates-table.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { partial } from '../../../../../../test/util';
import type { BranchConfig, BranchUpgradeConfig } from '../../../../types';
import { getPrUpdatesTable } from './updates-table';

Expand All @@ -15,7 +16,7 @@ describe('workers/repository/update/pr/body/updates-table', () => {
});

it('checks results for getPrUpdatesTable', () => {
const upgrade0: BranchUpgradeConfig = {
const upgrade0 = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: 'some-branch',
prBodyDefinitions: {
Expand All @@ -30,9 +31,9 @@ describe('workers/repository/update/pr/body/updates-table', () => {
'Package file': '{{{packageFile}}}',
},
updateType: 'lockFileMaintenance',
};
});

const upgrade1: BranchUpgradeConfig = {
const upgrade1 = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: 'some-branch',
prBodyDefinitions: {
Expand All @@ -57,9 +58,9 @@ describe('workers/repository/update/pr/body/updates-table', () => {
newVersion: '1.7.0',
displayFrom: '^1.7.0',
displayTo: '1.7.0',
};
});

const upgrade2: BranchUpgradeConfig = {
const upgrade2 = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: 'some-branch',
prBodyDefinitions: {
Expand All @@ -85,7 +86,7 @@ describe('workers/repository/update/pr/body/updates-table', () => {
newVersion: '6.2.3',
displayFrom: '^6.2.3',
displayTo: '6.2.3',
};
});
// TODO #7154 allow or filter undefined
const upgrade3 = undefined as never;
const configObj: BranchConfig = {
Expand Down
8 changes: 4 additions & 4 deletions lib/workers/repository/update/pr/changelog/github.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getChangeLogJSON } from '.';

jest.mock('../../../../../modules/datasource/npm');

const upgrade: BranchUpgradeConfig = {
const upgrade = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: '',
depName: 'renovate',
Expand All @@ -31,7 +31,7 @@ const upgrade: BranchUpgradeConfig = {
{ version: '2.4.2', releaseTimestamp: '2017-12-24T03:20:46.238Z' },
{ version: '2.5.2' },
],
};
});

describe('workers/repository/update/pr/changelog/github', () => {
afterEach(() => {
Expand Down Expand Up @@ -369,7 +369,7 @@ describe('workers/repository/update/pr/changelog/github', () => {
])
);

const upgradeData: BranchUpgradeConfig = {
const upgradeData = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: '',
depName: 'correctPrefix/target',
Expand All @@ -382,7 +382,7 @@ describe('workers/repository/update/pr/changelog/github', () => {
{ version: '1.0.1', gitRef: '123456' },
{ version: '0.1.1', gitRef: 'npm_1.0.0' },
],
};
});
expect(
await getChangeLogJSON({
...upgradeData,
Expand Down
5 changes: 3 additions & 2 deletions lib/workers/repository/update/pr/changelog/gitlab.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as httpMock from '../../../../../../test/http-mock';
import { partial } from '../../../../../../test/util';
import * as semverVersioning from '../../../../../modules/versioning/semver';
import * as hostRules from '../../../../../util/host-rules';
import type { BranchUpgradeConfig } from '../../../../types';
import { getChangeLogJSON } from '.';

jest.mock('../../../../../modules/datasource/npm');

const upgrade: BranchUpgradeConfig = {
const upgrade = partial<BranchUpgradeConfig>({
manager: 'some-manager',
branchName: '',
endpoint: 'https://gitlab.com/api/v4/ ',
Expand All @@ -26,7 +27,7 @@ const upgrade: BranchUpgradeConfig = {
{ version: '5.6.0', releaseTimestamp: '2020-02-13T15:37:00.000Z' },
{ version: '5.6.1' },
],
};
});

const matchHost = 'https://gitlab.com/';

Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/update/pr/changelog/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const githubApiHost = 'https://api.github.com';
const githubTagsMock = jest.spyOn(githubGraphql, 'queryTags');
const githubReleasesMock = jest.spyOn(githubGraphql, 'queryReleases');

const upgrade: BranchConfig = partial<BranchConfig>({
const upgrade = partial<BranchConfig>({
endpoint: 'https://api.github.com/',
depName: 'renovate',
versioning: semverVersioning.id,
Expand Down
Loading