Skip to content

Commit

Permalink
test(SingleInputComponent): add expect and fix warning (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtsvetkov-splunk authored Nov 20, 2024
1 parent 2574451 commit 180c28d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
<SingleInputComponent {...baseProps} dependencyValues={{ name: true, region: false }} />
);
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(<SingleInputComponent {...baseProps} dependencyValues={{ name: 0, region: 0 }} />);
await userEvent.click(screen.getByRole('combobox'));
await screen.findByRole('option', { name: fourthEntry.content.testLabel });
expect(
await screen.findByRole('option', { name: fourthEntry.content.testLabel })
).toBeInTheDocument();
});

0 comments on commit 180c28d

Please sign in to comment.