All files / test/test-utils get-message-and-path-from-captured-text.js

100% Statements 17/17
100% Branches 2/2
100% Functions 1/1
100% Lines 16/16

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 2614x     3x 3x 158x 3x   3x 3x 3x 3x   3x 3x 3x 3x   3x   3x     3x    
module.exports.getMessageAndPathFromCapturedText = getMessageAndPathFromCapturedText;
 
function getMessageAndPathFromCapturedText(pattern, capturedText) {
  const messages = [];
  for (let i = 0; i < capturedText.length; i++) {
    if (capturedText[i].includes(pattern)) {
      const aMessage = [];
 
      const messageMap = new Map();
      const messageSplit = capturedText[i].split(':');
      messageMap.set(messageSplit[0].trim(), messageSplit[1].trim());
      aMessage.push(messageMap);
 
      const pathMap = new Map();
      const pathSplit = capturedText[i + 1].split(':');
      pathMap.set(pathSplit[0].trim(), pathSplit[1].trim());
      aMessage.push(pathMap);
 
      messages.push(aMessage);
      // we jump the index by one due to that i+1 entry is already processed
      i++;
    }
  }
  return messages;
}