aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2021-04-03 18:05:20 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2021-04-04 17:34:57 +0900
commit4d043107b80e104c3a029acb405dd69a8371a9a8 (patch)
treeb2fed6bcbc2457998e00c3c4efbacd27047bf523 /test
parentc6795c190b582b4d00b13a9051f2c0c33527451c (diff)
Make Completion as a React.FC
Diffstat (limited to 'test')
-rw-r--r--test/console/components/console/Completion.test.tsx61
1 files changed, 40 insertions, 21 deletions
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(
- <Completion completions={completions} size={3} select={1} />
- );
+ let component: ReturnType<ReactTestRenderer["create"]> | null = null;
+
+ ReactTestRenderer.act(() => {
+ component = ReactTestRenderer.create(
+ <Completion completions={completions} size={3} select={1} />
+ );
+ });
+
const root = component.root;
let items = root.findAllByType(CompletionItem);
@@ -126,9 +131,11 @@ describe("console/components/console/completion/Completion", () => {
false,
]);
- component.update(
- <Completion completions={completions} size={3} select={2} />
- );
+ ReactTestRenderer.act(() => {
+ component.update(
+ <Completion completions={completions} size={3} select={2} />
+ );
+ });
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(
- <Completion completions={completions} size={3} select={3} />
- );
+ ReactTestRenderer.act(() => {
+ component.update(
+ <Completion completions={completions} size={3} select={3} />
+ );
+ });
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(
- <Completion completions={completions} size={3} select={5} />
- );
+ let component: ReturnType<ReactTestRenderer["create"]> | null = null;
+
+ ReactTestRenderer.act(() => {
+ component = ReactTestRenderer.create(
+ <Completion completions={completions} size={3} select={5} />
+ );
+ });
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(
- <Completion completions={completions} size={3} select={4} />
- );
+ ReactTestRenderer.act(() => {
+ component.update(
+ <Completion completions={completions} size={3} select={4} />
+ );
+ });
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(
- <Completion completions={completions} size={3} select={3} />
- );
+ ReactTestRenderer.act(() => {
+ component.update(
+ <Completion completions={completions} size={3} select={3} />
+ );
+ });
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(
- <Completion completions={completions} size={3} select={2} />
- );
+ ReactTestRenderer.act(() => {
+ component.update(
+ <Completion completions={completions} size={3} select={2} />
+ );
+ });
items = root.findAllByType(CompletionItem);
showns = root
.findAllByProps({ role: "group" })