From 4d043107b80e104c3a029acb405dd69a8371a9a8 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 3 Apr 2021 18:05:20 +0900 Subject: Make Completion as a React.FC --- .../console/components/console/Completion.test.tsx | 61 ++++++++++++++-------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/console/components/console/Completion.test.tsx b/test/console/components/console/Completion.test.tsx index 0e4e21f..9b47637 100644 --- a/test/console/components/console/Completion.test.tsx +++ b/test/console/components/console/Completion.test.tsx @@ -100,9 +100,14 @@ describe("console/components/console/completion/Completion", () => { }); it("scrolls up to down with select", () => { - const component = ReactTestRenderer.create( - - ); + let component: ReturnType | null = null; + + ReactTestRenderer.act(() => { + component = ReactTestRenderer.create( + + ); + }); + const root = component.root; let items = root.findAllByType(CompletionItem); @@ -126,9 +131,11 @@ describe("console/components/console/completion/Completion", () => { false, ]); - component.update( - - ); + ReactTestRenderer.act(() => { + component.update( + + ); + }); items = root.findAllByType(CompletionItem); showns = root .findAllByProps({ role: "group" }) @@ -151,9 +158,11 @@ describe("console/components/console/completion/Completion", () => { ]); expect(items[2].props.highlight).to.be.true; - component.update( - - ); + ReactTestRenderer.act(() => { + component.update( + + ); + }); items = root.findAllByType(CompletionItem); showns = root .findAllByProps({ role: "group" }) @@ -178,9 +187,13 @@ describe("console/components/console/completion/Completion", () => { }); it("scrolls down to up with select", () => { - const component = ReactTestRenderer.create( - - ); + let component: ReturnType | null = null; + + ReactTestRenderer.act(() => { + component = ReactTestRenderer.create( + + ); + }); const root = component.root; let items = root.findAllByType(CompletionItem); @@ -206,9 +219,11 @@ describe("console/components/console/completion/Completion", () => { ]); expect(items[5].props.highlight).to.be.true; - component.update( - - ); + ReactTestRenderer.act(() => { + component.update( + + ); + }); items = root.findAllByType(CompletionItem); showns = root .findAllByProps({ role: "group" }) @@ -231,9 +246,11 @@ describe("console/components/console/completion/Completion", () => { ]); expect(items[4].props.highlight).to.be.true; - component.update( - - ); + ReactTestRenderer.act(() => { + component.update( + + ); + }); items = root.findAllByType(CompletionItem); showns = root .findAllByProps({ role: "group" }) @@ -256,9 +273,11 @@ describe("console/components/console/completion/Completion", () => { ]); expect(items[3].props.highlight).to.be.true; - component.update( - - ); + ReactTestRenderer.act(() => { + component.update( + + ); + }); items = root.findAllByType(CompletionItem); showns = root .findAllByProps({ role: "group" }) -- cgit v1.2.3