Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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
const summaries = ReactTestUtils.findAllInRenderedTree(tree, (component) => ReactTestUtils.isCompositeComponentWithType(component, VoteSummary));
expect(summaries.length).toEqual(3);
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;
}));
}
function findAll(target, predicate) {
return TestUtils.findAllInRenderedTree(target, function(item) {
if (TestUtils.isCompositeComponent(item)) {
return false;
}
return predicate(createRenderedElement(item));
}).map(createRenderedElement);
}
constructor(reactElement) {
this._root = renderIntoDocument(reactElement)
this.all = findAllInRenderedTree(this._root, _.isObject)
}
export function scryRenderedDOMComponentsWithMarker(root, marker) {
return findAllInRenderedTree(root, (inst) => (
isDOMComponent(inst)
&& findDOMNode(inst).getAttribute('data-marker') === marker
));
}
function findAllComponent(target, component) {
return TestUtils.findAllInRenderedTree(target, function(item) {
return TestUtils.isCompositeComponentWithType(item, component);
}).map(createRenderedComponent);
}
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);
}
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)
},