Skip to content

test: improve tests#140

Open
JB1905 wants to merge 3 commits into
mainfrom
111
Open

test: improve tests#140
JB1905 wants to merge 3 commits into
mainfrom
111

Conversation

@JB1905

@JB1905 JB1905 commented Mar 10, 2023

Copy link
Copy Markdown
Owner

Closes #111

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Open in Devin Review

Comment on lines +52 to 55
const { container, getByText } = render(
<Checkbox id="uniqueId" readOnly disabled>
Label
</Checkbox>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟑 Disabled Checkbox test never passes onClick to component, making the assertion trivially true

In the 'should render disabled Checkbox' test, onClick is created as jest.fn() at line 50 but is never passed as a prop to the <Checkbox> component (lines 52-55). The test then asserts expect(onClick).not.toHaveBeenCalled() at line 62, which will always pass trivially since the handler was never connected to any element. This means the test does not actually verify that a disabled checkbox prevents click handling β€” it tests nothing meaningful about disabled behavior.

Compare with the other test cases in the same file: the 'unchecked Checkbox' test at line 14 correctly passes onClick={onClick}, and the 'custom className' test at line 74 also correctly passes it.

Suggested change
const { container, getByText } = render(
<Checkbox id="uniqueId" readOnly disabled>
Label
</Checkbox>
const { container, getByText } = render(
<Checkbox id="uniqueId" readOnly disabled onClick={onClick}>
Label
</Checkbox>
);
Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Comment on lines +38 to +44
it('', () => {
const { container } = render(
<Textarea value="Initial value" rows={2} disabled />
);

expect(container).toMatchSnapshot();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Textarea test with empty description string

The test at line 38 uses an empty string it('', () => {...}) as the test description. While this technically works, it produces unclear test output and appears to be an accidentally committed work-in-progress test (it duplicates the 'should render disabled Textarea' test at line 16 but without readOnly). The snapshot was also committed (__tests__/__snapshots__/Textarea.test.tsx.snap:3) showing Textarea 1 as the snapshot name, further indicating this is unfinished work.

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Comment on lines +7 to +8
// TODO: check, uncheck
// TODO onChange

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Many TODO comments suggest this PR is work-in-progress

The PR introduces numerous TODO comments across multiple test files (Checkbox, Disclosure, IconButton, Input, OnboardingTip, Radio, SelectMenu, Switch, Textarea) indicating incomplete test coverage for onChange handlers, disabled states, default selected states, and close handlers. This suggests the PR is an intermediate step and may benefit from being split or completed before merge.

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve tests

1 participant