Fix test, add test to demonstrate how custom elements will work

This commit is contained in:
Jessica
2018-11-24 00:08:43 +09:00
parent cc8f6fcd7c
commit 8beb9e99a7
2 changed files with 17 additions and 4 deletions
@@ -43,14 +43,14 @@ function testInstance(inst: ReactTestInstance) {
inst.props = {
prop1: "p",
};
inst.type = "t";
testInstance(inst.find(n => n.type === "t"));
inst.type = "a";
testInstance(inst.find(n => n.type === "a"));
testInstance(inst.findByProps({ prop1: "p" }));
testInstance(inst.findByType("t"));
testInstance(inst.findByType("a"));
testInstance(inst.findByType(TestComponent));
inst.findAll(n => n.type === "t", { deep: true }).map(testInstance);
inst.findAllByProps({ prop1: "p" }, { deep: true }).map(testInstance);
inst.findAllByType("t", { deep: true }).map(testInstance);
inst.findAllByType("a", { deep: true }).map(testInstance);
inst.findAllByType(TestComponent, { deep: true }).map(testInstance);
}
+13
View File
@@ -332,3 +332,16 @@ const HasFoo2: React.ReactType<{ foo: boolean }> = (props: { foo: boolean }) =>
const HasFoo3: React.ReactType<{ foo: boolean }> = (props: { foo: string }) => null; // $ExpectError
const HasHref: React.ReactType<{ href?: string }> = 'a';
const HasHref2: React.ReactType<{ href?: string }> = 'div'; // $ExpectError
const CustomElement: React.ReactType = 'my-undeclared-element'; // $ExpectError
// custom elements now need to be declared as intrinsic elements
declare global {
namespace JSX {
interface IntrinsicElements {
'my-declared-element': {};
}
}
}
const CustomElement2: React.ReactType = 'my-declared-element';