All files / app/assets/javascripts/batch_comments/services drafts_service.js

70% Statements 7/10
100% Branches 0/0
62.5% Functions 5/8
70% Lines 7/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34        2x 2x   2x     2x           2x     1x     2x                      
import axios from '~/lib/utils/axios_utils';
 
export default {
  createNewDraft(endpoint, data) {
    const postData = { ...data, draft_note: data.note };
    delete postData.note;
 
    return axios.post(endpoint, postData);
  },
  deleteDraft(endpoint, draftId) {
    return axios.delete(`${endpoint}/${draftId}`);
  },
  publishDraft(endpoint, draftId) {
    return axios.post(endpoint, { id: draftId });
  },
  addDraftToDiscussion(endpoint, data) {
    return axios.post(endpoint, data);
  },
  fetchDrafts(endpoint) {
    return axios.get(endpoint);
  },
  publish(endpoint) {
    return axios.post(endpoint);
  },
  discard(endpoint) {
    return axios.delete(endpoint);
  },
  update(endpoint, { draftId, note, resolveDiscussion, position }) {
    return axios.put(`${endpoint}/${draftId}`, {
      draft_note: { note, resolve_discussion: resolveDiscussion, position },
    });
  },
};