How to use the inferno-test-utils.renderIntoDocument function in inferno-test-utils

To help you get started, we’ve selected a few inferno-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 styletron / styletron / packages / styletron-inferno / src / __tests__ / browser.js View on Github external
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();
});
github infernojs / inferno / packages / inferno-test-utils / __tests__ / testutilevents.spec.jsx View on Github external
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);
  });
});
github styletron / styletron / packages / styletron-inferno / src / __tests__ / browser.js View on Github external
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))
  );
});