All files / module/mutations removeMutation.js

75% Statements 3/4
50% Branches 1/2
66.67% Functions 2/3
75% Lines 3/4

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                                  3x   1x 1x              
import Vue from 'vue'
 
/**
 * Remove a ResourceObject from a module's item(s)
 *
 * As with most mutations, the behaviour of deletion is slightly
 * different depending on wether we're dealing with a collection or
 * a single item.
 *
 * If we're working on a collection, this mutation has to called as
 * `commit('module/remove', id)`, while, when working with an item,
 * calling `commit('module/remove')` is sufficient. For convenience,
 * any payload given is ignored when in item-only operation.
 *
 * @param {Boolean} isCollection
 */
export function removeMutation (isCollection) {
  return new Proxy((state, payload) => {}, {
    apply (target, thisArg, [state, id]) {
      Eif (isCollection) {
        Vue.delete(state.items, id)
      } else {
        Vue.set(state, 'item', {})
      }
    }
  })
}