Skip to content

Commit 49d480a

Browse files
committed
test
1 parent 0f942ae commit 49d480a

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

packages/compass-components/src/components/accordion.spec.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import React from 'react';
22
import { expect } from 'chai';
33

4-
import {
5-
fireEvent,
6-
render,
7-
screen,
8-
cleanup,
9-
} from '@mongodb-js/testing-library-compass';
4+
import { userEvent, render, screen } from '@mongodb-js/testing-library-compass';
105

116
import { Accordion } from './accordion';
127

@@ -21,25 +16,36 @@ function renderAccordion(
2116
}
2217

2318
describe('Accordion Component', function () {
24-
afterEach(cleanup);
25-
2619
it('should open the accordion on click', function () {
2720
renderAccordion();
2821

2922
expect(screen.getByTestId('my-test-id')).to.exist;
3023
const button = screen.getByText('Accordion Test');
31-
fireEvent.click(button);
24+
userEvent.click(button);
25+
expect(screen.getByText('Hello World')).to.be.visible;
26+
});
27+
28+
it('should close the accordion on click - default open', function () {
29+
renderAccordion({
30+
defaultOpen: true,
31+
});
32+
33+
expect(screen.getByTestId('my-test-id')).to.exist;
34+
const button = screen.getByText('Accordion Test');
3235
expect(screen.getByText('Hello World')).to.be.visible;
36+
userEvent.click(button);
37+
38+
expect(screen.queryByText('Hello World')).not.to.exist;
3339
});
3440

3541
it('should close the accordion after clicking to open then close', function () {
3642
renderAccordion();
3743

3844
expect(screen.getByTestId('my-test-id')).to.exist;
3945
const button = screen.getByText('Accordion Test');
40-
fireEvent.click(button);
46+
userEvent.click(button);
4147
expect(screen.getByText('Hello World')).to.be.visible;
42-
fireEvent.click(button);
48+
userEvent.click(button);
4349
expect(screen.queryByText('Hello World')).to.not.exist;
4450
});
4551

packages/compass-components/src/components/accordion.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface AccordionProps extends React.HTMLProps<HTMLButtonElement> {
5252
hintText?: string;
5353
textClassName?: string;
5454
open?: boolean;
55-
isDefaultExpanded?: boolean;
55+
defaultOpen?: boolean;
5656
setOpen?: (newValue: boolean) => void;
5757
}
5858
function Accordion({
@@ -61,11 +61,11 @@ function Accordion({
6161
textClassName,
6262
open: _open,
6363
setOpen: _setOpen,
64-
isDefaultExpanded = false,
64+
defaultOpen = false,
6565
...props
6666
}: React.PropsWithChildren<AccordionProps>): React.ReactElement {
6767
const darkMode = useDarkMode();
68-
const [localOpen, setLocalOpen] = useState(_open ?? isDefaultExpanded);
68+
const [localOpen, setLocalOpen] = useState(_open ?? defaultOpen);
6969
const setOpenRef = useRef(_setOpen);
7070
setOpenRef.current = _setOpen;
7171
const onOpenChange = useCallback(() => {

packages/compass-data-modeling/src/components/diagram-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const DiagramEditor: React.FunctionComponent<{
230230
onCollectionSelect: (namespace: string) => void;
231231
onRelationshipSelect: (rId: string) => void;
232232
onDiagramBackgroundClicked: () => void;
233-
selectedItems: SelectedItems | null;
233+
selectedItems: SelectedItems;
234234
}> = ({
235235
diagramLabel,
236236
step,

packages/compass-data-modeling/src/components/relationship-drawer-content.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const RelationshipDrawerContent: React.FunctionComponent<
172172
<div data-relationship-id={relationshipId} className={containerStyles}>
173173
<Accordion
174174
text="RELATIONSHIP"
175-
isDefaultExpanded={true}
175+
defaultOpen={true}
176176
textClassName={accordionTitleStyles}
177177
>
178178
<FormFieldContainer className={formFieldContainerStyles}>
@@ -204,7 +204,7 @@ const RelationshipDrawerContent: React.FunctionComponent<
204204

205205
<Accordion
206206
text="CONFIGURATION"
207-
isDefaultExpanded={true}
207+
defaultOpen={true}
208208
textClassName={accordionTitleStyles}
209209
>
210210
<FormFieldContainer className={formFieldContainerStyles}>

0 commit comments

Comments
 (0)