summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2019-09-10 08:51:35 +0200
committerPaul Slaughter <pslaughter@gitlab.com>2019-09-10 11:23:54 -0500
commiteb954ce256e20a595da9f812c32c6aae2d0c3aff (patch)
treebd04bf1bca114e42b8aa2cde3d5c7edbfd0dd1e1
parent63cb8c2a561fe9f7f0802860875aa0e96a74b265 (diff)
downloadgitlab-ce-winh-vue-resource-sidebar-service-again.tar.gz
Replace hard-coded strings with endpoint constantswinh-vue-resource-sidebar-service-again
(cherry picked from commit b552aa9ecb344e54095ceed4806a5f4cca965453)
-rw-r--r--spec/javascripts/sidebar/sidebar_mediator_spec.js22
1 files changed, 9 insertions, 13 deletions
diff --git a/spec/javascripts/sidebar/sidebar_mediator_spec.js b/spec/javascripts/sidebar/sidebar_mediator_spec.js
index bf397d87e09..b0412105e3f 100644
--- a/spec/javascripts/sidebar/sidebar_mediator_spec.js
+++ b/spec/javascripts/sidebar/sidebar_mediator_spec.js
@@ -31,7 +31,7 @@ describe('Sidebar mediator', function() {
});
it('saves assignees', done => {
- mock.onPut('/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras').reply(200, {});
+ mock.onPut(mediatorMockData.endpoint).reply(200, {});
this.mediator
.saveAssignees('issue[assignee_ids]')
.then(resp => {
@@ -42,11 +42,8 @@ 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);
+ const mockData = Mock.responseMap.GET[mediatorMockData.endpoint];
+ mock.onGet(mediatorMockData.endpoint).reply(200, mockData);
spyOn(this.mediator, 'processFetchedData').and.callThrough();
this.mediator
@@ -59,8 +56,7 @@ describe('Sidebar mediator', function() {
});
it('processes fetched data', () => {
- const mockData =
- Mock.responseMap.GET['/gitlab-org/gitlab-shell/issues/5.json?serializer=sidebar_extras'];
+ const mockData = Mock.responseMap.GET[mediatorMockData.endpoint];
this.mediator.processFetchedData(mockData);
expect(this.mediator.store.assignees).toEqual(mockData.assignees);
@@ -83,7 +79,7 @@ describe('Sidebar mediator', function() {
it('fetches autocomplete projects', done => {
const searchTerm = 'foo';
- mock.onGet('/autocomplete/projects?project_id=15').reply(200, {});
+ mock.onGet(mediatorMockData.projectsAutocompleteEndpoint).reply(200, {});
spyOn(this.mediator.service, 'getProjectsAutocomplete').and.callThrough();
spyOn(this.mediator.store, 'setAutocompleteProjects').and.callThrough();
@@ -98,9 +94,9 @@ describe('Sidebar mediator', function() {
});
it('moves issue', done => {
- const mockData = Mock.responseMap.POST['/gitlab-org/gitlab-shell/issues/5/move'];
+ const mockData = Mock.responseMap.POST[mediatorMockData.moveIssueEndpoint];
const moveToProjectId = 7;
- mock.onPost('/gitlab-org/gitlab-shell/issues/5/move').reply(200, mockData);
+ mock.onPost(mediatorMockData.moveIssueEndpoint).reply(200, mockData);
this.mediator.store.setMoveToProjectId(moveToProjectId);
spyOn(this.mediator.service, 'moveIssue').and.callThrough();
const visitUrl = spyOnDependency(SidebarMediator, 'visitUrl');
@@ -109,7 +105,7 @@ describe('Sidebar mediator', function() {
.moveIssue()
.then(() => {
expect(this.mediator.service.moveIssue).toHaveBeenCalledWith(moveToProjectId);
- expect(visitUrl).toHaveBeenCalledWith('/root/some-project/issues/5');
+ expect(visitUrl).toHaveBeenCalledWith(mockData.web_url);
})
.then(done)
.catch(done.fail);
@@ -117,7 +113,7 @@ 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, {});
+ mock.onPost(mediatorMockData.toggleSubscriptionEndpoint).reply(200, {});
spyOn(this.mediator.service, 'toggleSubscription').and.callThrough();
this.mediator