How to use the react-addons-test-utils.findAllInRenderedTree function in react-addons-test-utils

To help you get started, we’ve selected a few react-addons-test-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Legitcode / tests / src / middleware / find.js View on Github external
// id
      case '#':
        els = TestUtils.findAllInRenderedTree(self.instance, function(component){
          if (component.id === subselector.slice(1)){
            return true
          }
        })
        foundElements.push( Array.isArray(els) ? els : [els] )
        break

      // data attribute
      case '[':
        var attributeName = _.first( subselector.slice(1,-1).split('=') )
        var attributeValue = subselector.slice(1,-1).split('=').slice(1).join('=').replace(/^"(.*)"$/, '$1')

        els = TestUtils.findAllInRenderedTree(self.instance, function(component){
          if (component.getAttribute) {
            var val = component.getAttribute(attributeName)
            if (val === attributeValue || (val === 'true' && attributeValue === '')){
              return true
            }
          }
        })

        foundElements.push( Array.isArray(els) ? els : [els] )
        break

      // tag
      default:
        els = TestUtils.scryRenderedDOMComponentsWithTag(self.instance, subselector)
        foundElements.push( Array.isArray(els) ? els : [els] )
        break
github nilshartmann / react-vote-example / test / components / VoteList.spec.js View on Github external
    const summaries = ReactTestUtils.findAllInRenderedTree(tree, (component) => ReactTestUtils.isCompositeComponentWithType(component, VoteSummary));
    expect(summaries.length).toEqual(3);
github subschema / subschema / test / support / index.js View on Github external
function byName(root, name) {
    return onlyOne(TestUtils.findAllInRenderedTree(root, function (inst) {
        if (!TestUtils.isDOMComponent(inst)) {
            return false;
        }
        var inode = findNode(inst);
        return inode.name === name;
    }));
}
github jamiebuilds / react-test-renderer / index.js View on Github external
function findAll(target, predicate) {
  return TestUtils.findAllInRenderedTree(target, function(item) {
    if (TestUtils.isCompositeComponent(item)) {
      return false;
    }

    return predicate(createRenderedElement(item));
  }).map(createRenderedElement);
}
github microsoft / fluent-ui-react / test / utils / RenderedTree.js View on Github external
constructor(reactElement) {
    this._root = renderIntoDocument(reactElement)
    this.all = findAllInRenderedTree(this._root, _.isObject)
  }
github vslinko / ripster / src / frontend / utils / testUtils.js View on Github external
export function scryRenderedDOMComponentsWithMarker(root, marker) {
  return findAllInRenderedTree(root, (inst) => (
    isDOMComponent(inst)
      && findDOMNode(inst).getAttribute('data-marker') === marker
  ));
}
github jamiebuilds / react-test-renderer / index.js View on Github external
function findAllComponent(target, component) {
  return TestUtils.findAllInRenderedTree(target, function(item) {
    return TestUtils.isCompositeComponentWithType(item, component);
  }).map(createRenderedComponent);
}
github subschema / subschema / test / support / index.js View on Github external
function byId(node, id) {
    var all = TestUtils.findAllInRenderedTree(node, function (inst) {
        if (!TestUtils.isDOMComponent(inst)) {
            return false;
        }
        var inode = findNode(inst);
        return inode.id === id;
    });
    return onlyOne(all);
}
github jquense / teaspoon / index.js View on Github external
var components;

    if( typeof selector === 'function') {
      components = utils.scryRenderedComponentsWithType(this.context, selector)
      selector = selector.name || '<>'
    }
    else if ( !selector )
      components = utils.findAllInRenderedTree(this.context, function(){ return true })

    else if( selector === ':dom' )
      components = utils.findAllInRenderedTree(this.context, function(item){
        return utils.isDOMComponent(item)
      })

    else if( selector === ':composite' )
      components = utils.findAllInRenderedTree(this.context, function(item){
        return !utils.isDOMComponent(item)
      })

    else if ( selector[0] === '.' )
      components = utils.scryRenderedDOMComponentsWithClass(this.context, selector.substr(1))

    else
      components = utils.scryRenderedDOMComponentsWithTag(this.context, selector)

    return new ComponentCollection(components, this.context, selector)
  },