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
path: root/spec
diff options
context:
space:
mode:
authorConstance Okoghenun <cokoghenun@gitlab.com>2019-01-10 17:00:36 +0300
committerPhil Hughes <me@iamphill.com>2019-01-10 17:00:36 +0300
commit211c946a672c1500cb512d13438d60658b07b9cd (patch)
tree52f1d814f5c999a8c9340a94f42114685a8eb8e2 /spec
parentbe855cc6a2b85da2ec3e51e0f767099dc87991e6 (diff)
Discussion filters - ensured note links resolves to the right note
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/notes/components/discussion_filter_spec.js46
1 files changed, 41 insertions, 5 deletions
diff --git a/spec/javascripts/notes/components/discussion_filter_spec.js b/spec/javascripts/notes/components/discussion_filter_spec.js
index 5efcab436e4..91dab58ba7f 100644
--- a/spec/javascripts/notes/components/discussion_filter_spec.js
+++ b/spec/javascripts/notes/components/discussion_filter_spec.js
@@ -1,6 +1,7 @@
import Vue from 'vue';
import createStore from '~/notes/stores';
import DiscussionFilter from '~/notes/components/discussion_filter.vue';
+import { DISCUSSION_FILTERS_DEFAULT_VALUE } from '~/notes/constants';
import { mountComponentWithStore } from '../../helpers/vue_mount_component_helper';
import { discussionFiltersMock, discussionMock } from '../mock_data';
@@ -20,16 +21,14 @@ describe('DiscussionFilter component', () => {
},
];
const Component = Vue.extend(DiscussionFilter);
- const selectedValue = discussionFiltersMock[0].value;
+ const selectedValue = DISCUSSION_FILTERS_DEFAULT_VALUE;
+ const props = { filters: discussionFiltersMock, selectedValue };
store.state.discussions = discussions;
return mountComponentWithStore(Component, {
el: null,
store,
- props: {
- filters: discussionFiltersMock,
- selectedValue,
- },
+ props,
});
};
@@ -115,4 +114,41 @@ describe('DiscussionFilter component', () => {
});
});
});
+
+ describe('URL with Links to notes', () => {
+ afterEach(() => {
+ window.location.hash = '';
+ });
+
+ it('updates the filter when the URL links to a note', done => {
+ window.location.hash = `note_${discussionMock.notes[0].id}`;
+ vm.currentValue = discussionFiltersMock[2].value;
+ vm.handleLocationHash();
+
+ vm.$nextTick(() => {
+ expect(vm.currentValue).toEqual(DISCUSSION_FILTERS_DEFAULT_VALUE);
+ done();
+ });
+ });
+
+ it('does not update the filter when the current filter is "Show all activity"', done => {
+ window.location.hash = `note_${discussionMock.notes[0].id}`;
+ vm.handleLocationHash();
+
+ vm.$nextTick(() => {
+ expect(vm.currentValue).toEqual(DISCUSSION_FILTERS_DEFAULT_VALUE);
+ done();
+ });
+ });
+
+ it('only updates filter when the URL links to a note', done => {
+ window.location.hash = `testing123`;
+ vm.handleLocationHash();
+
+ vm.$nextTick(() => {
+ expect(vm.currentValue).toEqual(DISCUSSION_FILTERS_DEFAULT_VALUE);
+ done();
+ });
+ });
+ });
});