From 180c28db9ac9139e7ee89c38d14c66c38f70ee8c Mon Sep 17 00:00:00 2001
From: Viktor Tsvetkov <142901247+vtsvetkov-splunk@users.noreply.github.com>
Date: Wed, 20 Nov 2024 11:34:34 +0100
Subject: [PATCH] test(SingleInputComponent): add expect and fix warning
(#1467)
---
ui/.eslintrc.js | 1 +
.../SingleInputComponent.test.tsx | 16 ++++++++++++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js
index 5f68acd17..f160bb342 100644
--- a/ui/.eslintrc.js
+++ b/ui/.eslintrc.js
@@ -26,6 +26,7 @@ module.exports = {
// https://typescript-eslint.io/rules/no-use-before-define/#how-to-use
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error', { variables: false }],
+ 'jest/expect-expect': 'error',
},
root: true,
};
diff --git a/ui/src/components/SingleInputComponent/SingleInputComponent.test.tsx b/ui/src/components/SingleInputComponent/SingleInputComponent.test.tsx
index f4c2b624d..e8563e1e1 100644
--- a/ui/src/components/SingleInputComponent/SingleInputComponent.test.tsx
+++ b/ui/src/components/SingleInputComponent/SingleInputComponent.test.tsx
@@ -207,7 +207,9 @@ it('should fetch options from API when endpointUrl is provided', async () => {
/>
);
await userEvent.click(screen.getByRole('combobox'));
- await screen.findByRole('option', { name: firstEntry.content.testLabel });
+ expect(
+ await screen.findByRole('option', { name: firstEntry.content.testLabel })
+ ).toBeInTheDocument();
const secondEntry = mockedEntries[1];
rerender(
@@ -217,17 +219,23 @@ it('should fetch options from API when endpointUrl is provided', async () => {
/>
);
await userEvent.click(screen.getByRole('combobox'));
- await screen.findByRole('option', { name: secondEntry.content.testLabel });
+ expect(
+ await screen.findByRole('option', { name: secondEntry.content.testLabel })
+ ).toBeInTheDocument();
const thirdEntry = mockedEntries[2];
rerender(
);
await userEvent.click(screen.getByRole('combobox'));
- await screen.findByRole('option', { name: thirdEntry.content.testLabel });
+ expect(
+ await screen.findByRole('option', { name: thirdEntry.content.testLabel })
+ ).toBeInTheDocument();
const fourthEntry = mockedEntries[3];
rerender();
await userEvent.click(screen.getByRole('combobox'));
- await screen.findByRole('option', { name: fourthEntry.content.testLabel });
+ expect(
+ await screen.findByRole('option', { name: fourthEntry.content.testLabel })
+ ).toBeInTheDocument();
});