All files / module/helpers setResourceObjectsForModule.js

87.5% Statements 7/8
50% Branches 2/4
100% Functions 1/1
87.5% Lines 7/8

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                    2x 4x 4x 4x   4x       4x   4x        
import { hasOwn } from '../../shared/utils'
 
/**
 *
 * @param {*} vuexFns
 * @param {*} currentModule
 * @param {*} destinationModule
 * @param {*} objects
 */
export function setResourceObjectsForModule (vuexFns, currentModule, destinationModule, objects) {
  for (const id in objects) {
    Eif (hasOwn(objects, id)) {
      const isRootMutation = currentModule !== destinationModule
      let mutation = 'set'
 
      Iif (isRootMutation) {
        mutation = destinationModule + '/' + mutation
      }
 
      const payload = { id: objects[id].id, data: objects[id] }
 
      vuexFns.commit(mutation, payload, { root: isRootMutation })
    }
  }
}