summaryrefslogtreecommitdiff
path: root/spec/frontend/notes/components/note_body_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/notes/components/note_body_spec.js')
-rw-r--r--spec/frontend/notes/components/note_body_spec.js56
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/frontend/notes/components/note_body_spec.js b/spec/frontend/notes/components/note_body_spec.js
index 3c11c266f90..4922de987fa 100644
--- a/spec/frontend/notes/components/note_body_spec.js
+++ b/spec/frontend/notes/components/note_body_spec.js
@@ -1,6 +1,14 @@
+import { shallowMount } from '@vue/test-utils';
import Vue from 'vue';
-import createStore from '~/notes/stores';
+import Vuex from 'vuex';
+
+import { suggestionCommitMessage } from '~/diffs/store/getters';
import noteBody from '~/notes/components/note_body.vue';
+import createStore from '~/notes/stores';
+import notes from '~/notes/stores/modules/index';
+
+import Suggestions from '~/vue_shared/components/markdown/suggestions.vue';
+
import { noteableDataMock, notesDataMock, note } from '../mock_data';
describe('issue_note_body component', () => {
@@ -54,4 +62,50 @@ describe('issue_note_body component', () => {
expect(vm.autosave.key).toEqual(autosaveKey);
});
});
+
+ describe('commitMessage', () => {
+ let wrapper;
+
+ Vue.use(Vuex);
+
+ beforeEach(() => {
+ const notesStore = notes();
+
+ notesStore.state.notes = {};
+
+ store = new Vuex.Store({
+ modules: {
+ notes: notesStore,
+ diffs: {
+ namespaced: true,
+ state: {
+ defaultSuggestionCommitMessage:
+ '%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}',
+ branchName: 'branch',
+ projectPath: '/path',
+ projectName: 'name',
+ username: 'user',
+ userFullName: 'user userton',
+ },
+ getters: { suggestionCommitMessage },
+ },
+ },
+ });
+
+ wrapper = shallowMount(noteBody, {
+ store,
+ propsData: {
+ note: { ...note, suggestions: [12345] },
+ canEdit: true,
+ file: { file_path: 'abc' },
+ },
+ });
+ });
+
+ it('passes the correct default placeholder commit message for a suggestion to the suggestions component', () => {
+ const commitMessage = wrapper.find(Suggestions).attributes('defaultcommitmessage');
+
+ expect(commitMessage).toBe('branch/pathnameuseruser usertonabc11');
+ });
+ });
});