Commit 2e760d20 authored by Eric Eastwood's avatar Eric Eastwood

Move json parsing to client code outside service

parent a818b3f5
......@@ -10,26 +10,22 @@ class RelatedIssuesService {
// eslint-disable-next-line class-methods-use-this
fetchIssueInfo(endpoint) {
return Vue.http.get(endpoint)
.then(res => res.json());
return Vue.http.get(endpoint);
}
fetchRelatedIssues() {
return this.relatedIssuesResource.get()
.then(res => res.json());
return this.relatedIssuesResource.get();
}
addRelatedIssues(newIssueReferences) {
return this.relatedIssuesResource.save({}, {
issue_references: newIssueReferences,
})
.then(res => res.json());
});
}
// eslint-disable-next-line class-methods-use-this
removeRelatedIssue(endpoint) {
return Vue.http.delete(endpoint)
.then(res => res.json());
return Vue.http.delete(endpoint);
}
}
......
......@@ -34,6 +34,7 @@ describe('RelatedIssuesService', () => {
it('fetch issue info', (done) => {
service.fetchIssueInfo('...')
.then(res => res.json())
.then((issue) => {
expect(issue).toEqual(issuable1);
done();
......@@ -61,6 +62,7 @@ describe('RelatedIssuesService', () => {
it('fetch related issues', (done) => {
service.fetchRelatedIssues()
.then(res => res.json())
.then((relatedIssues) => {
expect(relatedIssues).toEqual([issuable1]);
done();
......@@ -91,6 +93,7 @@ describe('RelatedIssuesService', () => {
it('add related issues', (done) => {
service.addRelatedIssues([issuable1.reference])
.then(res => res.json())
.then((resData) => {
expect(resData.status).toEqual('success');
done();
......@@ -121,6 +124,7 @@ describe('RelatedIssuesService', () => {
it('remove related issue', (done) => {
service.removeRelatedIssue('...')
.then(res => res.json())
.then((resData) => {
expect(resData.status).toEqual('success');
done();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment