Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/tests/testRenderer/unexpected-react-testrenderer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ describe('unexpected-react (test renderer)', function () {
const comp = ReactTestRenderer.create(<ClassComponent content={<span>hi</span>} />);
expect(comp, 'to have rendered', <div className="class-component"><span>hi</span></div>);
});


it('works with strings', function () {
const comp = ReactTestRenderer.create(() => 'foo');
expect(comp, 'to have rendered', 'foo');
});

it('works with nulls', function () {
const comp = ReactTestRenderer.create(() => null);
expect(comp, 'to have rendered', null);
});

it('highlights the error if the content does not match', function () {

const comp = ReactTestRenderer.create(<ClassComponent content={<span>hi</span>} />);
Expand Down
3 changes: 2 additions & 1 deletion src/types/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function installInto(expect) {

identify: function (value) {
return React.isValidElement(value) ||
value === null ||
typeof value === 'string' ||
(typeof value === 'object' &&
value !== null &&
(typeof value.type === 'function' || typeof value.type === 'string') &&
typeof value.hasOwnProperty === 'function' &&
value.hasOwnProperty('props') &&
Expand Down