Skip to content

Commit

Permalink
finishing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandrichardson committed Aug 15, 2017
1 parent da98fef commit a315d72
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions src/ReactWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ class ReactWrapper {
'ReactWrapper::getNode() can only be called when wrapping one node',
);
}
// TODO(lmr): the public API for this was to return an instance, but we use it internally like
// a "return a node", so it's unclear what we should be doing here. Publicly, we should be using
// instance() instead.
return this.nodes[0];
}

Expand Down Expand Up @@ -238,7 +235,6 @@ class ReactWrapper {
*/
update() {
if (this.root !== this) {
// TODO(lmr): this requirement may not be necessary for the ReactWrapper
throw new Error('ReactWrapper::update() can only be called on the root');
}
this.single('update', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/ReactSixteenAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function toTree(vnode) {
return {
nodeType: 'class',
type: node.type,
props: { ...node.memoizedProps },
props: { ...vnode.memoizedProps },
key: node.key,
ref: node.ref,
instance: node.stateNode,
Expand All @@ -77,7 +77,7 @@ function toTree(vnode) {
return {
nodeType: 'function',
type: node.type,
props: { ...node.memoizedProps },
props: { ...vnode.memoizedProps },
key: node.key,
ref: node.ref,
instance: null,
Expand Down
7 changes: 2 additions & 5 deletions test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,7 @@ describeWithDOM('mount', () => {

});

// TODO(lmr): for some reason these tests are causing mocha to freeze. need to look
// into this before merging
describeIf(!REACT16, '.setProps(newProps[, callback])', () => {
describe('.setProps(newProps[, callback])', () => {
it('should set props for a component multiple times', () => {
class Foo extends React.Component {
render() {
Expand Down Expand Up @@ -1039,7 +1037,7 @@ describeWithDOM('mount', () => {
expect(setInvalidProps).to.throw(TypeError, similarException.message);
});

it('should call the callback when setProps has completed', () => {
itIf(!REACT16, 'should call the callback when setProps has completed', () => {
class Foo extends React.Component {
render() {
return (
Expand Down Expand Up @@ -1815,7 +1813,6 @@ describeWithDOM('mount', () => {
});

describeIf(!REACT013, 'stateless function components', () => {
// TODO(lmr): this is broken now
it('should return props of root rendered node', () => {
const Foo = ({ bar, foo }) => (
<div className={bar} id={foo} />
Expand Down
12 changes: 6 additions & 6 deletions test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ describe('shallow', () => {

expect(() => wrapper.context()).to.throw(
Error,
'ShallowWrapper::context() can only be called on class components as of React 16',
'ShallowWrapper::context() can only be called on wrapped nodes that have a non-null instance',
);
expect(() => wrapper.context('name')).to.throw(
Error,
'ShallowWrapper::context() can only be called on class components as of React 16',
'ShallowWrapper::context() can only be called on wrapped nodes that have a non-null instance',
);
});
});
Expand Down Expand Up @@ -2515,11 +2515,11 @@ describe('shallow', () => {

expect(() => wrapper.context()).to.throw(
Error,
'ShallowWrapper::context() can only be called on class components as of React 16',
'ShallowWrapper::context() can only be called on wrapped nodes that have a non-null instance',
);
expect(() => wrapper.context('name')).to.throw(
Error,
'ShallowWrapper::context() can only be called on class components as of React 16',
'ShallowWrapper::context() can only be called on wrapped nodes that have a non-null instance',
);
});
});
Expand Down Expand Up @@ -4273,7 +4273,7 @@ describe('shallow', () => {
const wrapper = shallow(<Test />);
wrapper.find('.async-btn').simulate('click');
setImmediate(() => {
wrapper.update(); // TODO(lmr): this is a breaking change...
wrapper.update();
expect(wrapper.find('.show-me').length).to.equal(1);
done();
});
Expand All @@ -4282,7 +4282,7 @@ describe('shallow', () => {
it('should have updated output after child prop callback invokes setState', () => {
const wrapper = shallow(<Test />);
wrapper.find(Child).props().callback();
wrapper.update(); // TODO(lmr): this is a breaking change...
wrapper.update();
expect(wrapper.find('.show-me').length).to.equal(1);
});
});
Expand Down

0 comments on commit a315d72

Please sign in to comment.