diff options
author | Mike Greiling <mike@pixelcog.com> | 2019-09-03 22:44:56 +0000 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-09-03 22:44:56 +0000 |
commit | 3399335602f3dbd5822899979ffba6c3fa833c56 (patch) | |
tree | 3254ecaa3dc3dff53a51771f4f69f3e9967d3966 /spec/javascripts | |
parent | 89409a1925d65d4a62b523b5a7c0650287250cb5 (diff) | |
download | gitlab-ce-3399335602f3dbd5822899979ffba6c3fa833c56.tar.gz |
Revert "Merge branch 'remove-vue-resource-from-sidebar-service' into 'master'"
This reverts merge request !32400
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/sidebar/mock_data.js | 10 | ||||
-rw-r--r-- | spec/javascripts/sidebar/sidebar_mediator_spec.js | 19 | ||||
-rw-r--r-- | spec/javascripts/sidebar/sidebar_move_issue_spec.js | 13 |
3 files changed, 19 insertions, 23 deletions
diff --git a/spec/javascripts/sidebar/mock_data.js b/spec/javascripts/sidebar/mock_data.js index 3ee97b978fd..7f20b0da991 100644 --- a/spec/javascripts/sidebar/mock_data.js +++ b/spec/javascripts/sidebar/mock_data.js @@ -210,4 +210,14 @@ const mockData = { }, }; +mockData.sidebarMockInterceptor = function(request, next) { + const body = this.responseMap[request.method.toUpperCase()][request.url]; + + next( + request.respondWith(JSON.stringify(body), { + status: 200, + }), + ); +}.bind(mockData); + export default mockData; diff --git a/spec/javascripts/sidebar/sidebar_mediator_spec.js b/spec/javascripts/sidebar/sidebar_mediator_spec.js index 2e5845cd847..6c69c08e733 100644 --- a/spec/javascripts/sidebar/sidebar_mediator_spec.js +++ b/spec/javascripts/sidebar/sidebar_mediator_spec.js @@ -1,16 +1,13 @@ -import MockAdapter from 'axios-mock-adapter'; -import axios from '~/lib/utils/axios_utils'; +import _ from 'underscore'; +import Vue from 'vue'; import SidebarMediator from '~/sidebar/sidebar_mediator'; import SidebarStore from '~/sidebar/stores/sidebar_store'; import SidebarService from '~/sidebar/services/sidebar_service'; import Mock from './mock_data'; describe('Sidebar mediator', function() { - let mock; - beforeEach(() => { - mock = new MockAdapter(axios); - + Vue.http.interceptors.push(Mock.sidebarMockInterceptor); this.mediator = new SidebarMediator(Mock.mediator); }); @@ -18,7 +15,7 @@ describe('Sidebar mediator', function() { SidebarService.singleton = null; SidebarStore.singleton = null; SidebarMediator.singleton = null; - mock.restore(); + Vue.http.interceptors = _.without(Vue.http.interceptors, Mock.sidebarMockInterceptor); }); it('assigns yourself ', () => { @@ -29,7 +26,6 @@ describe('Sidebar mediator', function() { }); it('saves assignees', done => { - mock.onPut('/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras').reply(200, {}); this.mediator .saveAssignees('issue[assignee_ids]') .then(resp => { @@ -42,9 +38,6 @@ describe('Sidebar mediator', function() { it('fetches the data', done => { const mockData = Mock.responseMap.GET['/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras']; - mock - .onGet('/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras') - .reply(200, mockData); spyOn(this.mediator, 'processFetchedData').and.callThrough(); this.mediator @@ -81,7 +74,6 @@ describe('Sidebar mediator', function() { it('fetches autocomplete projects', done => { const searchTerm = 'foo'; - mock.onGet('/autocomplete/projects?project_id=15').reply(200, {}); spyOn(this.mediator.service, 'getProjectsAutocomplete').and.callThrough(); spyOn(this.mediator.store, 'setAutocompleteProjects').and.callThrough(); @@ -96,9 +88,7 @@ describe('Sidebar mediator', function() { }); it('moves issue', done => { - const mockData = Mock.responseMap.POST['/gitlab-org/gitlab-shell/issues/5/move']; const moveToProjectId = 7; - mock.onPost('/gitlab-org/gitlab-shell/issues/5/move').reply(200, mockData); this.mediator.store.setMoveToProjectId(moveToProjectId); spyOn(this.mediator.service, 'moveIssue').and.callThrough(); const visitUrl = spyOnDependency(SidebarMediator, 'visitUrl'); @@ -115,7 +105,6 @@ describe('Sidebar mediator', function() { it('toggle subscription', done => { this.mediator.store.setSubscribedState(false); - mock.onPost('/gitlab-org/gitlab-shell/issues/5/toggle_subscription').reply(200, {}); spyOn(this.mediator.service, 'toggleSubscription').and.callThrough(); this.mediator diff --git a/spec/javascripts/sidebar/sidebar_move_issue_spec.js b/spec/javascripts/sidebar/sidebar_move_issue_spec.js index ec712450f2e..230e0a933a9 100644 --- a/spec/javascripts/sidebar/sidebar_move_issue_spec.js +++ b/spec/javascripts/sidebar/sidebar_move_issue_spec.js @@ -1,6 +1,6 @@ import $ from 'jquery'; -import MockAdapter from 'axios-mock-adapter'; -import axios from '~/lib/utils/axios_utils'; +import _ from 'underscore'; +import Vue from 'vue'; import SidebarMediator from '~/sidebar/sidebar_mediator'; import SidebarStore from '~/sidebar/stores/sidebar_store'; import SidebarService from '~/sidebar/services/sidebar_service'; @@ -8,12 +8,8 @@ import SidebarMoveIssue from '~/sidebar/lib/sidebar_move_issue'; import Mock from './mock_data'; describe('SidebarMoveIssue', function() { - let mock; - beforeEach(() => { - mock = new MockAdapter(axios); - const mockData = Mock.responseMap.GET['/autocomplete/projects?project_id=15']; - mock.onGet('/autocomplete/projects?project_id=15').reply(200, mockData); + Vue.http.interceptors.push(Mock.sidebarMockInterceptor); this.mediator = new SidebarMediator(Mock.mediator); this.$content = $(` <div class="dropdown"> @@ -41,7 +37,8 @@ describe('SidebarMoveIssue', function() { SidebarMediator.singleton = null; this.sidebarMoveIssue.destroy(); - mock.restore(); + + Vue.http.interceptors = _.without(Vue.http.interceptors, Mock.sidebarMockInterceptor); }); describe('init', () => { |