Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js')
-rw-r--r--spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js44
1 files changed, 27 insertions, 17 deletions
diff --git a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
index 1f3b6dce620..bf208f16d18 100644
--- a/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
+++ b/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js
@@ -13,7 +13,12 @@ import {
} from '~/vue_merge_request_widget/components/approvals/messages';
import eventHub from '~/vue_merge_request_widget/event_hub';
-jest.mock('~/flash');
+const mockAlertDismiss = jest.fn();
+jest.mock('~/flash', () => ({
+ createAlert: jest.fn().mockImplementation(() => ({
+ dismiss: mockAlertDismiss,
+ })),
+}));
const RULE_NAME = 'first_rule';
const TEST_HELP_PATH = 'help/path';
@@ -87,6 +92,8 @@ describe('MRWidget approvals', () => {
approvalRules: [],
isOpen: true,
state: 'open',
+ targetProjectFullPath: 'gitlab-org/gitlab',
+ iid: '1',
};
jest.spyOn(eventHub, '$emit').mockImplementation(() => {});
@@ -98,21 +105,18 @@ describe('MRWidget approvals', () => {
});
describe('when created', () => {
- beforeEach(() => {
- createComponent();
- });
-
- it('shows loading message', () => {
- // setData usage is discouraged. See https://gitlab.com/groups/gitlab-org/-/epics/7330 for details
- // eslint-disable-next-line no-restricted-syntax
- wrapper.setData({ fetchingApprovals: true });
+ it('shows loading message', async () => {
+ service = {
+ fetchApprovals: jest.fn().mockReturnValue(new Promise(() => {})),
+ };
- return nextTick().then(() => {
- expect(wrapper.text()).toContain(FETCH_LOADING);
- });
+ createComponent();
+ await nextTick();
+ expect(wrapper.text()).toContain(FETCH_LOADING);
});
it('fetches approvals', () => {
+ createComponent();
expect(service.fetchApprovals).toHaveBeenCalled();
});
});
@@ -267,9 +271,16 @@ describe('MRWidget approvals', () => {
return nextTick();
});
- it('flashes error message', () => {
+ it('shows an alert with error message', () => {
expect(createAlert).toHaveBeenCalledWith({ message: APPROVE_ERROR });
});
+
+ it('clears the previous alert', () => {
+ expect(mockAlertDismiss).toHaveBeenCalledTimes(0);
+
+ findAction().vm.$emit('click');
+ expect(mockAlertDismiss).toHaveBeenCalledTimes(1);
+ });
});
});
});
@@ -377,15 +388,14 @@ describe('MRWidget approvals', () => {
});
it('is rendered with props', () => {
- const expected = testApprovals();
const summary = findSummary();
expect(findOptionalSummary().exists()).toBe(false);
expect(summary.exists()).toBe(true);
expect(summary.props()).toMatchObject({
- approvalsLeft: expected.approvals_left,
- rulesLeft: expected.approval_rules_left,
- approvers: testApprovedBy(),
+ projectPath: 'gitlab-org/gitlab',
+ iid: '1',
+ updatedCount: 0,
});
});
});