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/deploy_freeze/store')
-rw-r--r--spec/frontend/deploy_freeze/store/actions_spec.js45
-rw-r--r--spec/frontend/deploy_freeze/store/mutations_spec.js6
2 files changed, 48 insertions, 3 deletions
diff --git a/spec/frontend/deploy_freeze/store/actions_spec.js b/spec/frontend/deploy_freeze/store/actions_spec.js
index 6bc9c4d374c..ad67afdce75 100644
--- a/spec/frontend/deploy_freeze/store/actions_spec.js
+++ b/spec/frontend/deploy_freeze/store/actions_spec.js
@@ -5,6 +5,7 @@ import * as actions from '~/deploy_freeze/store/actions';
import * as types from '~/deploy_freeze/store/mutation_types';
import getInitialState from '~/deploy_freeze/store/state';
import createFlash from '~/flash';
+import * as logger from '~/lib/logger';
import axios from '~/lib/utils/axios_utils';
import { freezePeriodsFixture, timezoneDataFixture } from '../helpers';
@@ -12,6 +13,7 @@ jest.mock('~/api.js');
jest.mock('~/flash.js');
describe('deploy freeze store actions', () => {
+ const freezePeriodFixture = freezePeriodsFixture[0];
let mock;
let state;
@@ -24,6 +26,7 @@ describe('deploy freeze store actions', () => {
Api.freezePeriods.mockResolvedValue({ data: freezePeriodsFixture });
Api.createFreezePeriod.mockResolvedValue();
Api.updateFreezePeriod.mockResolvedValue();
+ Api.deleteFreezePeriod.mockResolvedValue();
});
afterEach(() => {
@@ -195,4 +198,46 @@ describe('deploy freeze store actions', () => {
);
});
});
+
+ describe('deleteFreezePeriod', () => {
+ it('dispatch correct actions on deleting a freeze period', () => {
+ testAction(
+ actions.deleteFreezePeriod,
+ freezePeriodFixture,
+ state,
+ [
+ { type: 'REQUEST_DELETE_FREEZE_PERIOD', payload: freezePeriodFixture.id },
+ { type: 'RECEIVE_DELETE_FREEZE_PERIOD_SUCCESS', payload: freezePeriodFixture.id },
+ ],
+ [],
+ () =>
+ expect(Api.deleteFreezePeriod).toHaveBeenCalledWith(
+ state.projectId,
+ freezePeriodFixture.id,
+ ),
+ );
+ });
+
+ it('should show flash error and set error in state on delete failure', () => {
+ jest.spyOn(logger, 'logError').mockImplementation();
+ const error = new Error();
+ Api.deleteFreezePeriod.mockRejectedValue(error);
+
+ testAction(
+ actions.deleteFreezePeriod,
+ freezePeriodFixture,
+ state,
+ [
+ { type: 'REQUEST_DELETE_FREEZE_PERIOD', payload: freezePeriodFixture.id },
+ { type: 'RECEIVE_DELETE_FREEZE_PERIOD_ERROR', payload: freezePeriodFixture.id },
+ ],
+ [],
+ () => {
+ expect(createFlash).toHaveBeenCalled();
+
+ expect(logger.logError).toHaveBeenCalledWith('Unable to delete deploy freeze', error);
+ },
+ );
+ });
+ });
});
diff --git a/spec/frontend/deploy_freeze/store/mutations_spec.js b/spec/frontend/deploy_freeze/store/mutations_spec.js
index f8683489340..878a755088c 100644
--- a/spec/frontend/deploy_freeze/store/mutations_spec.js
+++ b/spec/frontend/deploy_freeze/store/mutations_spec.js
@@ -28,9 +28,9 @@ describe('Deploy freeze mutations', () => {
describe('RECEIVE_FREEZE_PERIODS_SUCCESS', () => {
it('should set freeze periods and format timezones from identifiers to names', () => {
const timezoneNames = {
- 'Europe/Berlin': 'Berlin',
- 'Etc/UTC': 'UTC',
- 'America/New_York': 'Eastern Time (US & Canada)',
+ 'Europe/Berlin': '[UTC 2] Berlin',
+ 'Etc/UTC': '[UTC 0] UTC',
+ 'America/New_York': '[UTC -4] Eastern Time (US & Canada)',
};
mutations[types.RECEIVE_FREEZE_PERIODS_SUCCESS](stateCopy, freezePeriodsFixture);