Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('styled applies styles object', t => {
const styletron = new StyletronServer();
const StyledComponent = styled('div', {color: 'red'});
const result = InfernoTestUtils.renderIntoDocument(
createElement(Provider, {styletron}, createElement(StyledComponent))
);
const element = InfernoTestUtils.findRenderedDOMElementWithTag(result, 'div');
t.equal(element.className, 'a', 'matches expected className');
t.equal(styletron.getCss(), '.a{color:red}', 'matches expected CSS');
t.end();
});
it('Should work with native events', () => {
const testObj = {
clicker: () => {}
};
const sinonSpy = sinon.spy(testObj, 'clicker');
class FooBar extends Component {
render() {
return <div>Test</div>;
}
}
const tree = renderIntoDocument();
const vnode = findRenderedVNodeWithType(tree, 'div');
vnode.dom.click();
expect(sinonSpy.callCount).toEqual(1);
});
});
class ClassComponent extends InfernoComponent {
componentDidMount() {
t.ok(this.styledDiv instanceof HTMLDivElement, 'element ref passed');
}
render() {
return createElement(StyledComponent, {
innerRef: styledDiv => {
t.ok(styledDiv instanceof HTMLDivElement, 'element ref passed');
t.equal(styledDiv.className, 'a', 'matches expected className');
this.styledDiv = styledDiv;
},
});
}
}
InfernoTestUtils.renderIntoDocument(
createElement(Provider, {styletron}, createElement(ClassComponent))
);
});