Skip to content

Commit b99c7eb

Browse files
committed
address comment: refactor unit test
1 parent 1804f34 commit b99c7eb

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/compass-collection/src/components/mock-data-generator-modal/mock-data-generator-modal.spec.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ describe('MockDataGeneratorModal', () => {
5151
expect(screen.queryByTestId('generate-mock-data-modal')).to.not.exist;
5252
});
5353

54-
it('renders the correct step when currentStep is set', () => {
55-
renderModal({ currentStep: MockDataGeneratorStep.SCHEMA_CONFIRMATION });
56-
57-
expect(
58-
screen.getByTestId(
59-
`generate-mock-data-step-${MockDataGeneratorStep.SCHEMA_CONFIRMATION}`
60-
)
61-
).to.exist;
62-
});
63-
6454
it('calls setIsOpen(false) when the modal is closed', () => {
6555
renderModal();
6656

@@ -85,12 +75,18 @@ describe('MockDataGeneratorModal', () => {
8575
).to.equal('true');
8676
});
8777

88-
it('renders the next step button with the correct label on each step', () => {
89-
renderModal();
90-
91-
Object.values(StepButtonLabelMap).forEach((label) => {
92-
expect(screen.getByTestId('next-step-button')).to.have.text(label);
93-
screen.getByTestId('next-step-button').click();
78+
describe('when rendering the modal in a specific step', () => {
79+
const steps = Object.values(MockDataGeneratorStep).filter(
80+
(step) => typeof step === 'number'
81+
) as MockDataGeneratorStep[];
82+
83+
steps.forEach((currentStep) => {
84+
it(`renders the button with the correct label when the user is in step "${currentStep}"`, () => {
85+
renderModal({ currentStep });
86+
expect(screen.getByTestId('next-step-button')).to.have.text(
87+
StepButtonLabelMap[currentStep]
88+
);
89+
});
9490
});
9591
});
9692
});

0 commit comments

Comments
 (0)