Skip to content

Commit 077d8a1

Browse files
Increased test coverage
1 parent 16ad27d commit 077d8a1

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

test/assertComponent.test.mjs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,56 @@ describe("assertComponent.test.mjs", () => {
209209
);
210210
});
211211

212+
it("should fail if children count doesn't match", () => {
213+
//given
214+
const Comp = () => {
215+
return h("p", {}, h("hr", {}, h("div")));
216+
};
217+
const comp = TestRenderer.create(h(Comp)).root.children[0];
218+
/** @type {Error?} */
219+
let resError = null;
220+
221+
//when
222+
try {
223+
assertComponent(comp, h("p", {}, h("hr", {}, h("div"), h("div"))));
224+
} catch (error) {
225+
resError = error;
226+
}
227+
228+
//then
229+
assert.deepEqual(
230+
resError?.message,
231+
"Children count doesn't match for p > hr" +
232+
"\n\tactual: 1" +
233+
"\n\texpected: 2"
234+
);
235+
});
236+
237+
it("should fail if empty", () => {
238+
//given
239+
const Comp = () => {
240+
return h("p");
241+
};
242+
const comp = TestRenderer.create(h(Comp)).root.children[0];
243+
/** @type {Error?} */
244+
let resError = null;
245+
246+
//when
247+
try {
248+
assertComponent(comp, h("p", {}, h(TestComp)));
249+
} catch (error) {
250+
resError = error;
251+
}
252+
253+
//then
254+
assert.deepEqual(
255+
resError?.message,
256+
"Children count doesn't match for p" +
257+
"\n\tactual: 0" +
258+
"\n\texpected: 1"
259+
);
260+
});
261+
212262
it("should fail if non-empty", () => {
213263
//given
214264
const Comp = () => {
@@ -232,7 +282,7 @@ describe("assertComponent.test.mjs", () => {
232282
);
233283
});
234284

235-
it("should assert props and children", () => {
285+
it("should assert props and simple children", () => {
236286
//given
237287
const id = Date.now.toString();
238288
const Comp = () => {

0 commit comments

Comments
 (0)