Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('"onComponentWillUnmount" hook should fire, args DOM props', () => {
const spyObj = {
fn: () => {}
};
const sinonSpy = sinon.spy(spyObj, 'fn');
const node = template(null, null, spyObj.fn, null, null, null, StatelessComponent)({ a: 1 });
render(node, container);
expect(sinonSpy.callCount).toBe(0);
// do unmount
render(null, container);
expect(sinonSpy.callCount).toBe(1);
expect(sinonSpy.getCall(0).args.length).toBe(2);
expect(sinonSpy.getCall(0).args[0].outerHTML).toBe(innerHTML('<div>Hello world!</div>'));
expect(sinonSpy.getCall(0).args[1]).toEqual({ a: 1, children: null });
});
ConfigsList,
combineFrom(props, {
configs: this.state.configs,
configToChild: {
customProxyStringRaw: ProxyEditor
},
onConfChanged: this.handleModChange
})
);
}
}
render(<main>, container);
// Renders correctly
expect(innerHTML(container.innerHTML)).toBe(
innerHTML(
'<ol><li><input id="customProxyStringRaw" type="checkbox"><label for="customProxyStringRaw">Use proxy? (click this)</label><div></div></li><li><input id="This one is needed for reproduction too!" type="checkbox"><label for="This one is needed for reproduction too!">needed too</label><div></div></li></ol>'
)
);
let checkBoxes = container.querySelectorAll('input');
expect(checkBoxes.length).toBe(2);
expect(checkBoxes[0].checked).toBe(false);
expect(checkBoxes[1].checked).toBe(false);
checkBoxes[0].click(); // Click first checkbox
rerender();
checkBoxes = container.querySelectorAll('input');
</main>
it('Should be possible to use camelCase styles when reactStyles support is on', () => {
render(<div style="{{">Test</div>, container);
expect(innerHTML(container.innerHTML)).toBe(innerHTML(`<div style="background-color: red;">Test</div>`));
});
it('Should render element with a text string', function() {
const element = createElement('div', null, 'body text');
expect(isValidElement(element)).toBe(true);
renderCompatTestElement(element);
expect(container.innerHTML).toBe(innerHTML('<div>body text</div>'));
});
it('should insert an additional tag node', () => {
const template = child => createElement('div', null, child);
const div = () => createElement('div', null);
render(template(null), container);
expect(container.firstChild.innerHTML).toBe('');
render(template(div()), container);
expect(container.firstChild.innerHTML).toBe(innerHTML('<div></div>'));
});
it('should insert an additional tag node', () => {
const template = child => createElement('div', null, child);
const span = () => createElement('span', null);
render(template(span()), container);
expect(container.firstChild.innerHTML).toBe(innerHTML('<span></span>'));
render(template(null), container);
expect(container.firstChild.innerHTML).toBe('');
render(template(span()), container);
expect(container.firstChild.innerHTML).toBe(innerHTML('<span></span>'));
});
it('Should render a string div', () => {
const Div = 'div';
render(<div>Hello World</div>, container);
expect(container.innerHTML).toBe(innerHTML('<div>Hello World</div>'));
});
});
it('should patch a text node into a tag node', () => {
const template = child => createElement('div', null, child);
const span = function() {
return 'Hello';
};
render(template(span()), container);
expect(container.innerHTML).toBe(innerHTML('<div>Hello</div>'));
});
it('Should hydrate correctly when CSR component returns null', () => {
const container = createContainerWithHTML('<div></div>');
hydrate(
<div>
</div>,
container
);
expect(innerHTML(container.innerHTML)).toEqual(innerHTML('<div></div>'));
});
it('Should hydrate correctly when CSR children is missing', () => {
const container = createContainerWithHTML('<div> </div>');
hydrate(
,
container
);
expect(innerHTML(container.innerHTML)).toEqual(innerHTML(compHtml2));
});