All files / module/helpers setResourceObjectsForModule.js

85.71% Statements 6/7
50% Branches 1/2
100% Functions 2/2
85.71% Lines 6/7

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                  8x   8x   8x       8x                     8x   8x    
/**
 * Make sure we call the correct mutation depending on whether we're mutating
 * our own state or that of an included module.
 *
 * @param {string} currentModule
 * @param {string} destinationModule
 * @returns {string}
 */
function compileMutation (currentModule, destinationModule) {
  const isRootMutation = currentModule !== destinationModule
 
  let mutation = 'set'
 
  Iif (isRootMutation) {
    mutation = destinationModule + '/' + mutation
  }
 
  return { mutation, isRootMutation }
}
 
/**
 *
 * @param {*} vuexFns
 * @param {*} currentModule
 * @param {*} destinationModule
 * @param {*} objects
 */
export function setResourceObjectsForModule (vuexFns, currentModule, destinationModule, objects) {
  const { mutation, isRootMutation } = compileMutation(currentModule, destinationModule)
 
  vuexFns.commit(mutation, objects, { root: isRootMutation })
}