UNPKG

hbp-react-ui

Version:

A library of useful user-interface components built with React and MobX

66 lines (54 loc) 2.12 kB
import React from 'react'; import ReactDOM from 'react-dom'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import { NameValue, NameValueArray } from '../src/NameValue'; import StaticTextStyles from '../src/StaticTextStyles'; import StaticText from '../src/StaticText'; @observer class Component extends React.Component { item = new NameValue('Test'); constructor(props) { console.log('Component.constructor'); super(props); } render() { console.log('Component.render'); return ( <div style={StaticTextStyles.styleTable()}> <div style={StaticTextStyles.styleRowGroup()}> <div style={StaticTextStyles.styleRow()}> <div style={StaticTextStyles.styleCell()}> <StaticText path='/Category/Item' item={this.item} ref={(childComponent) => { this.childComponent = childComponent; }} /> </div> </div> </div> </div> ); } } QUnit.module('StaticText', function (hooks) { console.clear(); this.component = ReactDOM.render(<Component />, document.getElementById('react')); hooks.before(function (assert) { console.log('QUnit.hooks.before'); assert.ok(true, 'before'); }); QUnit.test('renderedParent', function (assert) { console.log('QUnit.' + assert.test.testName); assert.ok(typeof this.component.props == 'object', 'passed'); }); QUnit.test('rendered', function (assert) { console.log('QUnit.' + assert.test.testName); assert.ok(typeof this.component.childComponent.props == 'object', 'passed'); }); // hooks.after(function (assert) { // Not getting called here for some reason // console.log('QUnit.hooks.after'); // ReactDOM.unmountComponentAtNode(document.getElementById('react')); // assert.ok(true, 'after'); // }); });