debian-mirror-gitlab/spec/frontend/vue_merge_request_widget/stores/get_state_key_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import getStateKey from '~/vue_merge_request_widget/stores/get_state_key';
describe('getStateKey', () => {
it('should return proper state name', () => {
const context = {
mergeStatus: 'checked',
2019-09-04 21:01:54 +05:30
autoMergeEnabled: false,
2017-08-17 22:00:37 +05:30
canMerge: true,
onlyAllowMergeIfPipelineSucceeds: false,
isPipelineFailed: false,
hasMergeableDiscussionsState: false,
isPipelineBlocked: false,
canBeMerged: false,
2020-10-24 23:57:45 +05:30
projectArchived: false,
branchMissing: false,
commitsCount: 2,
hasConflicts: false,
2021-12-11 22:18:48 +05:30
draft: false,
2022-11-25 23:54:43 +05:30
detailedMergeStatus: null,
2017-08-17 22:00:37 +05:30
};
2020-10-24 23:57:45 +05:30
const bound = getStateKey.bind(context);
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual(null);
2022-11-25 23:54:43 +05:30
context.detailedMergeStatus = 'MERGEABLE';
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('readyToMerge');
2019-09-04 21:01:54 +05:30
context.autoMergeEnabled = true;
2020-11-24 15:15:51 +05:30
context.hasMergeableDiscussionsState = true;
2018-12-13 13:39:08 +05:30
2019-09-04 21:01:54 +05:30
expect(bound()).toEqual('autoMergeEnabled');
2017-08-17 22:00:37 +05:30
2020-05-24 23:13:21 +05:30
context.canMerge = true;
2019-02-15 15:39:39 +05:30
context.isSHAMismatch = true;
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('shaMismatch');
2020-05-24 23:13:21 +05:30
context.canMerge = false;
2022-11-25 23:54:43 +05:30
context.detailedMergeStatus = 'DISCUSSIONS_NOT_RESOLVED';
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('unresolvedDiscussions');
2022-11-25 23:54:43 +05:30
context.detailedMergeStatus = 'DRAFT_STATUS';
2020-07-28 23:09:34 +05:30
2021-12-11 22:18:48 +05:30
expect(bound()).toEqual('draft');
2020-07-28 23:09:34 +05:30
2022-11-25 23:54:43 +05:30
context.detailedMergeStatus = 'CI_MUST_PASS';
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('pipelineFailed');
2020-07-28 23:09:34 +05:30
context.shouldBeRebased = true;
2018-12-13 13:39:08 +05:30
2020-07-28 23:09:34 +05:30
expect(bound()).toEqual('rebase');
2017-08-17 22:00:37 +05:30
2020-10-24 23:57:45 +05:30
context.hasConflicts = true;
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('conflicts');
2022-11-25 23:54:43 +05:30
context.detailedMergeStatus = 'CHECKING';
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('checking');
2020-10-24 23:57:45 +05:30
context.commitsCount = 0;
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('nothingToMerge');
2021-12-11 22:18:48 +05:30
context.commitsCount = 1;
2020-10-24 23:57:45 +05:30
context.branchMissing = true;
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('missingBranch');
2020-10-24 23:57:45 +05:30
context.projectArchived = true;
2018-12-13 13:39:08 +05:30
2017-08-17 22:00:37 +05:30
expect(bound()).toEqual('archived');
});
2019-03-02 22:35:43 +05:30
it('returns rebased state key', () => {
const context = {
mergeStatus: 'checked',
2019-09-04 21:01:54 +05:30
autoMergeEnabled: false,
2019-03-02 22:35:43 +05:30
canMerge: true,
onlyAllowMergeIfPipelineSucceeds: true,
isPipelineFailed: true,
hasMergeableDiscussionsState: false,
isPipelineBlocked: false,
canBeMerged: false,
shouldBeRebased: true,
2020-10-24 23:57:45 +05:30
projectArchived: false,
branchMissing: false,
commitsCount: 2,
hasConflicts: false,
2021-12-11 22:18:48 +05:30
draft: false,
2019-03-02 22:35:43 +05:30
};
2020-10-24 23:57:45 +05:30
const bound = getStateKey.bind(context);
2019-03-02 22:35:43 +05:30
expect(bound()).toEqual('rebase');
});
2017-08-17 22:00:37 +05:30
});