Skip to content

Commit 0b5f0c3

Browse files
committed
Testing for the correct render count.
1 parent 0fadf19 commit 0b5f0c3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,22 @@ it("should render with custom defaults", async () => {
110110
assertSize({ width: 24, height: 42 });
111111
});
112112

113-
it("should follow size changes correctly without subpixels as they're used in CSS", async () => {
114-
const { setSize, assertSize } = await render(Observed);
113+
it("should follow size changes correctly with appropriate render count and without sub-pixels as they're used in CSS", async () => {
114+
const { setSize, assertSize, assertRenderCount } = await render(Observed);
115+
116+
// Default render
117+
assertRenderCount(1);
115118

116119
setSize({ width: 100, height: 200 });
117120
await delay(50);
121+
// One render for setting the CSS, and another for the hook to react
122+
assertRenderCount(3);
118123
assertSize({ width: 100, height: 200 });
119124

120125
setSize({ width: 321, height: 456 });
121126
await delay(50);
127+
// One render for setting the CSS, and another for the hook to react
128+
assertRenderCount(5);
122129
assertSize({ width: 321, height: 456 });
123130
});
124131

0 commit comments

Comments
 (0)