Skip to content

Commit

Permalink
[Tests] useEffect: Fix set document title test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenesan authored and ljharb committed Jun 11, 2019
1 parent 085be44 commit 5b08c0e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,27 @@ export default function describeUseEffect({
expect(setDocumentTitle.args).to.deep.equal([[expectedCountString(0)]]);
});

// TODO: useEffect fixme
it.skip('on didupdate', () => {
it('on didupdate', () => {
const wrapper = Wrap(<ClickCounterPage />);

expect(setDocumentTitle).to.have.property('callCount', 1);
expect(setDocumentTitle.args).to.deep.equal([[expectedCountString(0)]]);
const [firstCall] = setDocumentTitle.args;
expect(firstCall).to.deep.equal([expectedCountString(0)]);
expect(wrapper.find('p').text()).to.equal(expectedCountString(0));

const { onClick } = wrapper.find('button').props();
onClick();
wrapper.find('button').invoke('onClick')();

expect(setDocumentTitle).to.have.property('callCount', 2);
expect(setDocumentTitle.args).to.deep.equal([[expectedCountString(1)]]);
const [, secondCall] = setDocumentTitle.args;
expect(secondCall).to.deep.equal([expectedCountString(1)]);
expect(wrapper.find('p').text()).to.equal(expectedCountString(1));

onClick();
onClick();
wrapper.find('button').invoke('onClick')();
wrapper.find('button').invoke('onClick')();

expect(setDocumentTitle).to.have.property('callCount', 4);
expect(setDocumentTitle.args).to.deep.equal([[expectedCountString(3)]]);
const [,,, fourthCall] = setDocumentTitle.args;
expect(fourthCall).to.deep.equal([expectedCountString(3)]);
expect(wrapper.find('p').text()).to.equal(expectedCountString(3));
});
});
Expand Down Expand Up @@ -240,7 +241,9 @@ export default function describeUseEffect({

wrapper.unmount();

expect(ChatAPI.unsubscribeFromFriendStatus.calledOnceWith(friend.id)).to.equal(true);
expect(ChatAPI.unsubscribeFromFriendStatus).to.have.property('callCount', 1);
const [[firstArg]] = ChatAPI.unsubscribeFromFriendStatus.args;
expect(firstArg).to.equal(friend.id);
});
});
});
Expand Down

0 comments on commit 5b08c0e

Please sign in to comment.