summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2018-09-14 08:25:13 +0000
committerPhil Hughes <me@iamphill.com>2018-09-14 08:25:13 +0000
commitae5600b868308fd4094a8ddf1d6278fa6f5a5a7c (patch)
tree81f4f3a119ed6e293bb052188d41ea0ebf09c234 /spec
parent32b96bfd81ff254142dbd9c73e1a494308213cb3 (diff)
downloadgitlab-ce-ae5600b868308fd4094a8ddf1d6278fa6f5a5a7c.tar.gz
Create specs for diffs/components/app and update modules to export factory functions
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/diffs/components/app_spec.js72
-rw-r--r--spec/javascripts/diffs/components/changed_files_spec.js2
-rw-r--r--spec/javascripts/diffs/components/diff_file_header_spec.js11
-rw-r--r--spec/javascripts/diffs/create_diffs_store.js15
4 files changed, 93 insertions, 7 deletions
diff --git a/spec/javascripts/diffs/components/app_spec.js b/spec/javascripts/diffs/components/app_spec.js
index 7237274eb43..7be44a26ded 100644
--- a/spec/javascripts/diffs/components/app_spec.js
+++ b/spec/javascripts/diffs/components/app_spec.js
@@ -1 +1,71 @@
-// TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
+import Vue from 'vue';
+import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
+import { TEST_HOST } from 'spec/test_constants';
+import App from '~/diffs/components/app.vue';
+import createDiffsStore from '../create_diffs_store';
+
+describe('diffs/components/app', () => {
+ const oldMrTabs = window.mrTabs;
+ const Component = Vue.extend(App);
+
+ let vm;
+
+ beforeEach(() => {
+ // setup globals (needed for component to mount :/)
+ window.mrTabs = jasmine.createSpyObj('mrTabs', ['resetViewContainer']);
+
+ // setup component
+ const store = createDiffsStore();
+ store.state.diffs.isLoading = false;
+
+ vm = mountComponentWithStore(Component, {
+ store,
+ props: {
+ endpoint: `${TEST_HOST}/diff/endpoint`,
+ projectPath: 'namespace/project',
+ currentUser: {},
+ },
+ });
+ });
+
+ afterEach(() => {
+ // reset globals
+ window.mrTabs = oldMrTabs;
+
+ // reset component
+ vm.$destroy();
+ });
+
+ it('shows comments message, with commit', done => {
+ vm.$store.state.diffs.commit = {};
+
+ vm.$nextTick()
+ .then(() => {
+ expect(vm.$el).toContainText('Only comments from the following commit are shown below');
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+
+ it('shows comments message, with old mergeRequestDiff', done => {
+ vm.$store.state.diffs.mergeRequestDiff = { latest: false };
+
+ vm.$nextTick()
+ .then(() => {
+ expect(vm.$el).toContainText("Not all comments are displayed because you're viewing an old version of the diff.");
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+
+ it('shows comments message, with startVersion', done => {
+ vm.$store.state.diffs.startVersion = 'test';
+
+ vm.$nextTick()
+ .then(() => {
+ expect(vm.$el).toContainText("Not all comments are displayed because you're comparing two versions of the diff.");
+ })
+ .then(done)
+ .catch(done.fail);
+ });
+});
diff --git a/spec/javascripts/diffs/components/changed_files_spec.js b/spec/javascripts/diffs/components/changed_files_spec.js
index f737e8fa38e..7f21273a991 100644
--- a/spec/javascripts/diffs/components/changed_files_spec.js
+++ b/spec/javascripts/diffs/components/changed_files_spec.js
@@ -8,7 +8,7 @@ describe('ChangedFiles', () => {
const Component = Vue.extend(changedFiles);
const store = new Vuex.Store({
modules: {
- diffs: diffsModule,
+ diffs: diffsModule(),
},
});
diff --git a/spec/javascripts/diffs/components/diff_file_header_spec.js b/spec/javascripts/diffs/components/diff_file_header_spec.js
index 92b2004c4d7..c986ea604b2 100644
--- a/spec/javascripts/diffs/components/diff_file_header_spec.js
+++ b/spec/javascripts/diffs/components/diff_file_header_spec.js
@@ -16,8 +16,8 @@ describe('diff_file_header', () => {
const store = new Vuex.Store({
modules: {
- diffs: diffsModule,
- notes: notesModule,
+ diffs: diffsModule(),
+ notes: notesModule(),
},
});
@@ -450,13 +450,14 @@ describe('diff_file_header', () => {
propsCopy.diffFile.deletedFile = true;
const discussionGetter = () => [diffDiscussionMock];
- notesModule.getters.discussions = discussionGetter;
+ const notesModuleMock = notesModule();
+ notesModuleMock.getters.discussions = discussionGetter;
vm = mountComponentWithStore(Component, {
props: propsCopy,
store: new Vuex.Store({
modules: {
- diffs: diffsModule,
- notes: notesModule,
+ diffs: diffsModule(),
+ notes: notesModuleMock,
},
}),
});
diff --git a/spec/javascripts/diffs/create_diffs_store.js b/spec/javascripts/diffs/create_diffs_store.js
new file mode 100644
index 00000000000..aacde99964c
--- /dev/null
+++ b/spec/javascripts/diffs/create_diffs_store.js
@@ -0,0 +1,15 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import diffsModule from '~/diffs/store/modules';
+import notesModule from '~/notes/stores/modules';
+
+Vue.use(Vuex);
+
+export default function createDiffsStore() {
+ return new Vuex.Store({
+ modules: {
+ diffs: diffsModule(),
+ notes: notesModule(),
+ },
+ });
+}