All files / addon-test-support/properties/click-on-text helpers.js

100% Statements 8/8
100% Branches 6/6
100% Functions 2/2
100% Lines 8/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 27                  152x 152x   152x 89x         152x   152x 89x   63x      
import {
  assign,
  buildSelector as originalBuildSelector
} from '../../-private/helpers';
 
function childSelector(pageObjectNode, context, selector, options) {
  // Suppose that we have something like `<form><button>Submit</button></form>`
  // In this case <form> and <button> elements contains "Submit" text, so, we'll
  // want to __always__ click on the __last__ element that contains the text.
  let selectorWithSpace = `${selector || ''} `;
  let opts = assign({ last: true, multiple: true }, options);
 
  if (context.find(selectorWithSpace, opts).length) {
    return originalBuildSelector(pageObjectNode, selectorWithSpace, opts);
  }
}
 
export function buildSelector(pageObjectNode, context, selector, options) {
  let childSel = childSelector(pageObjectNode, context, selector, options);
 
  if (childSel) {
    return childSel;
  } else {
    return originalBuildSelector(pageObjectNode, selector, options);
  }
}