summaryrefslogtreecommitdiff
path: root/spec/frontend/releases/stores/modules/detail/actions_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/releases/stores/modules/detail/actions_spec.js')
-rw-r--r--spec/frontend/releases/stores/modules/detail/actions_spec.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js
index d8329fb82b1..41653f62ebf 100644
--- a/spec/frontend/releases/stores/modules/detail/actions_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js
@@ -1,8 +1,10 @@
import { cloneDeep } from 'lodash';
import originalOneReleaseForEditingQueryResponse from 'test_fixtures/graphql/releases/graphql/queries/one_release_for_editing.query.graphql.json';
import testAction from 'helpers/vuex_action_helper';
+import { getTag } from '~/api/tags_api';
import createFlash from '~/flash';
import { redirectTo } from '~/lib/utils/url_utility';
+import { s__ } from '~/locale';
import { ASSET_LINK_TYPE } from '~/releases/constants';
import createReleaseAssetLinkMutation from '~/releases/graphql/mutations/create_release_link.mutation.graphql';
import deleteReleaseAssetLinkMutation from '~/releases/graphql/mutations/delete_release_link.mutation.graphql';
@@ -12,6 +14,8 @@ import * as types from '~/releases/stores/modules/edit_new/mutation_types';
import createState from '~/releases/stores/modules/edit_new/state';
import { gqClient, convertOneReleaseGraphQLResponse } from '~/releases/util';
+jest.mock('~/api/tags_api');
+
jest.mock('~/flash');
jest.mock('~/lib/utils/url_utility', () => ({
@@ -567,4 +571,46 @@ describe('Release edit/new actions', () => {
});
});
});
+
+ describe('fetchTagNotes', () => {
+ const tagName = 'v8.0.0';
+
+ it('saves the tag notes on succes', async () => {
+ const tag = { message: 'this is a tag' };
+ getTag.mockResolvedValue({ data: tag });
+
+ await testAction(
+ actions.fetchTagNotes,
+ tagName,
+ state,
+ [
+ { type: types.REQUEST_TAG_NOTES },
+ { type: types.RECEIVE_TAG_NOTES_SUCCESS, payload: tag },
+ ],
+ [],
+ );
+
+ expect(getTag).toHaveBeenCalledWith(state.projectId, tagName);
+ });
+ it('creates a flash on error', async () => {
+ error = new Error();
+ getTag.mockRejectedValue(error);
+
+ await testAction(
+ actions.fetchTagNotes,
+ tagName,
+ state,
+ [
+ { type: types.REQUEST_TAG_NOTES },
+ { type: types.RECEIVE_TAG_NOTES_ERROR, payload: error },
+ ],
+ [],
+ );
+
+ expect(createFlash).toHaveBeenCalledWith({
+ message: s__('Release|Unable to fetch the tag notes.'),
+ });
+ expect(getTag).toHaveBeenCalledWith(state.projectId, tagName);
+ });
+ });
});