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

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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                                                     
import {
  assign,
  buildSelector as originalBuildSelector
} from '../../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);
  }
}