mirror of
https://github.com/bendtherules/react-fiber-traverse.git
synced 2026-08-18 13:52:36 +00:00
Add testcase - utils.isNodeHtmlLike - Add negative test cases where it is false
This commit is contained in:
@@ -4,6 +4,10 @@ import * as React from "react";
|
|||||||
import { isNodeHtmlLike, isNodeNotHtmlLike } from "../src/utils";
|
import { isNodeHtmlLike, isNodeNotHtmlLike } from "../src/utils";
|
||||||
import { mountAndGetRootNode } from "./utils/mountInEnzyme";
|
import { mountAndGetRootNode } from "./utils/mountInEnzyme";
|
||||||
import { FiberNodeForInstrinsicElement } from "../src/mocked-types";
|
import { FiberNodeForInstrinsicElement } from "../src/mocked-types";
|
||||||
|
import {
|
||||||
|
createFunctionComponent,
|
||||||
|
createClassComponent
|
||||||
|
} from "./utils/createComponent";
|
||||||
|
|
||||||
// Import test helpers and sample components
|
// Import test helpers and sample components
|
||||||
|
|
||||||
@@ -68,5 +72,31 @@ describe("utils", () => {
|
|||||||
expect(resultNegative).toBeFalsy();
|
expect(resultNegative).toBeFalsy();
|
||||||
expect(resultNegative).toBe(false);
|
expect(resultNegative).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not work for function component", () => {
|
||||||
|
const fn1 = createFunctionComponent("fn1");
|
||||||
|
const rootNode = mountAndGetRootNode(fn1, container);
|
||||||
|
|
||||||
|
const resultPositive = isNodeNotHtmlLike(rootNode);
|
||||||
|
const resultNegative = isNodeHtmlLike(rootNode);
|
||||||
|
|
||||||
|
expect(resultPositive).not.toBeFalsy();
|
||||||
|
expect(resultPositive).toBe(true);
|
||||||
|
expect(resultNegative).toBeFalsy();
|
||||||
|
expect(resultNegative).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not work for class component", () => {
|
||||||
|
const C1 = createClassComponent("C1");
|
||||||
|
const rootNode = mountAndGetRootNode(C1, container);
|
||||||
|
|
||||||
|
const resultPositive = isNodeNotHtmlLike(rootNode);
|
||||||
|
const resultNegative = isNodeHtmlLike(rootNode);
|
||||||
|
|
||||||
|
expect(resultPositive).not.toBeFalsy();
|
||||||
|
expect(resultPositive).toBe(true);
|
||||||
|
expect(resultNegative).toBeFalsy();
|
||||||
|
expect(resultNegative).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user