Skip to content

Commit

Permalink
correct tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Aug 27, 2022
1 parent b81478c commit e35a031
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/diff/index.js
Expand Up @@ -497,7 +497,9 @@ export function unmount(vnode, parentVNode, skipRemove) {
if (options.unmount) options.unmount(vnode);

if ((r = vnode.ref)) {
if (!r.current || r.current === vnode._dom) applyRef(r, null, parentVNode);
if (!r.current || r.current === vnode._dom) {
applyRef(r, null, parentVNode);
}
}

if ((r = vnode._component) != null) {
Expand Down
20 changes: 10 additions & 10 deletions test/browser/refs.test.js
Expand Up @@ -517,13 +517,16 @@ describe('refs', () => {
}

render(<App count={0} />, scratch);
expect(calls[0]).to.equal(scratch.firstChild.firstChild);
render(<App count={1} />, scratch);
expect(calls[1]).to.equal(null);
expect(calls[2]).to.equal(scratch.firstChild.firstChild);
render(<App count={2} />, scratch);
expect(calls[3]).to.equal(null);
expect(calls[4]).to.equal(scratch.firstChild.firstChild);
expect(calls.length).to.equal(5);
expect(calls).to.deep.equal([
scratch.firstChild.firstChild,
null,
scratch.firstChild.firstChild,
null,
scratch.firstChild.firstChild
]);
});

it('should properly call null for memoized components unkeyed', () => {
Expand All @@ -534,12 +537,9 @@ describe('refs', () => {
}

render(<App count={0} />, scratch);
expect(calls[0]).to.equal(scratch.firstChild.firstChild);
render(<App count={1} />, scratch);
expect(calls[1]).to.equal(null);
expect(calls[2]).to.equal(scratch.firstChild.firstChild);
render(<App count={2} />, scratch);
expect(calls[3]).to.equal(null);
expect(calls[4]).to.equal(scratch.firstChild.firstChild);
expect(calls.length).to.equal(1);
expect(calls[0]).to.equal(scratch.firstChild.firstChild);
});
});

0 comments on commit e35a031

Please sign in to comment.