Skip to content

Commit

Permalink
Test: Update interactions to account for Clear All button
Browse files Browse the repository at this point in the history
  • Loading branch information
meissadia committed Jul 19, 2023
1 parent dcd25d3 commit 4aa58d7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/Dropdown/Dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Default Dropdown', () => {
options: MockOptions,
onSelect,
placeholder,
defaultValue: MockOptions.at(-1)
defaultValue: MockOptions.at(2)
}}
/>
);
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('Multi-select Dropdown', () => {
});

const pills = screen.queryAllByRole('listitem');
expect(pills.length).toBe(1);
expect(pills.length).toBe(2);

const selectedOption = pills[0];
expect(selectedOption).toHaveClass('pill');
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Multi-select Dropdown', () => {
// Verify pill displayed
expect(screen.getByText(optionLabel)).toBeInTheDocument();
const afterSelection = screen.queryAllByRole('listitem');
expect(afterSelection.length).toBe(1);
expect(afterSelection.length).toBe(2);
expect(afterSelection[0]).toHaveClass('pill');
expect(afterSelection[0]).toHaveTextContent(optionLabel);

Expand All @@ -190,7 +190,8 @@ describe('Multi-select Dropdown', () => {

// Verify pills displayed
const afterSelection = screen.queryAllByRole('listitem');
expect(afterSelection.length).toBe(3);
// All options + Clear All button
expect(afterSelection.length).toBe(5);
expect(afterSelection[2]).toHaveClass('pill');
expect(afterSelection[2]).toHaveTextContent(optionLabel);

Expand All @@ -202,7 +203,7 @@ describe('Multi-select Dropdown', () => {

// Verify correct option's pill was removed, while others remain
const afterDelete = screen.queryAllByRole('listitem');
expect(afterDelete.length).toBe(2);
expect(afterDelete.length).toBe(4);
expect(afterDelete[0]).toHaveTextContent('Option B');
expect(afterDelete[1]).toHaveTextContent('Option C');
});
Expand Down

0 comments on commit 4aa58d7

Please sign in to comment.