Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Should work with namespace svg attributes', () => {
render(
createElement('svg', null, [
createElement('image', {
xlinkHref: 'http://i.imgur.com/w7GCRPb.png'
})
]),
container
);
expect(container.firstChild.firstChild.tagName).toBe('image');
expect(container.firstChild.firstChild.getAttribute('xlink:href')).toBe('http://i.imgur.com/w7GCRPb.png');
});
});
it('Should render element with an array of one child element', function() {
const child = createElement('span', null, 'child body text');
expect(isValidElement(child)).toBe(true);
const element = createElement('div', null, [child]);
expect(isValidElement(element)).toBe(true);
renderCompatTestElement(element);
expect(container.innerHTML).toBe(innerHTML('<div><span>child body text</span></div>'));
});
it('Should render element with an iterable of a child element and a string', function() {
const child = <span>generated child body text</span>;
expect(isValidElement(child)).toBe(true);
const iterable = arrayAsBasicIterator([child, 'generated body text']);
const element = createElement('div', null, iterable);
expect(isValidElement(element)).toBe(true);
renderCompatTestElement(element);
expect(container.innerHTML).toBe(innerHTML('<div><span>generated child body text</span>generated body text</div>'));
});
}
it('Should work with namespace svg attributes', () => {
render(
createElement('svg', null, [
createElement('image', {
xlinkHref: 'http://i.imgur.com/w7GCRPb.png'
})
]),
container
);
expect(container.firstChild.firstChild.tagName).toBe('image');
expect(container.firstChild.firstChild.getAttribute('xlink:href')).toBe('http://i.imgur.com/w7GCRPb.png');
});
});
it('allows a DOM element to be used with a string', function() {
var element = React.createElement('div', { className: 'foo' });
var instance = renderIntoDocument(element);
expect(ReactDOM.findDOMNode(instance).tagName).toBe('DIV');
});
it('Should render element with child element', function() {
const child = createElement('span', null, 'child body text');
expect(isValidElement(child)).toBe(true);
const element = createElement('div', null, child);
expect(isValidElement(element)).toBe(true);
renderCompatTestElement(element);
expect(container.innerHTML).toBe(innerHTML('<div><span>child body text</span></div>'));
});
ref: el => {
console.log('2b' + (el ? el.id : null));
}
},
null
)
]
);
}
}
render(createElement(Hello, { name: 'Inferno' }), container);
console.log('UPDATE');
render(createElement(Hello, { name: 'Better Lifecycle' }), container);
console.log('REMOVAL');
render(<div>, container);
const array = consoleSpy.getCalls();
expect(array.length).toEqual(42);
/*
React oder is:, Inferno will differenciate in string refs because they are handled same way as callback refs
Will mount
Will mount sub
S2bS2b
S1S1
Didountsub
4a4a</div>
it('Should render element with an array of two child elements', function() {
const first_child = createElement('span', null, 'first text');
expect(isValidElement(first_child)).toBe(true);
const second_child = createElement('span', null, 'second text');
expect(isValidElement(second_child)).toBe(true);
const element = createElement('div', null, [first_child, second_child]);
expect(isValidElement(element)).toBe(true);
renderCompatTestElement(element);
expect(container.innerHTML).toBe(innerHTML('<div><span>first text</span><span>second text</span></div>'));
});
render() {
const props = assign({}, this.props);
props.client = this.client;
if (operationOptions.withRef) props.ref = 'wrappedInstance';
return createElement(WrappedComponent, props);
}
}
render() {
if (this.shouldSkip()) {
return createElement(WrappedComponent, this.props);
}
const { shouldRerender, renderedElement, props } = this;
this.shouldRerender = false;
if (!shouldRerender && renderedElement && renderedElement.type === WrappedComponent) {
return renderedElement;
}
const data = this.dataForChild();
const clientProps = this.calculateResultProps(data);
const mergedPropsAndData = assign({}, props, clientProps);
if (operationOptions.withRef) mergedPropsAndData.ref = 'wrappedInstance';
this.renderedElement = createElement(WrappedComponent, mergedPropsAndData);
return this.renderedElement;