Skip to content

Convert enzyme tests to React Testing Library with help from Claude Code for ontology dir components#1994

Open
cnathe wants to merge 2 commits intodevelopfrom
fb_ontologyRTL
Open

Convert enzyme tests to React Testing Library with help from Claude Code for ontology dir components#1994
cnathe wants to merge 2 commits intodevelopfrom
fb_ontologyRTL

Conversation

@cnathe
Copy link
Copy Markdown
Contributor

@cnathe cnathe commented May 5, 2026

Rationale

Convert spec.tsx enzyme test files to RTL tests with the help from Claude Code for the ontology dir components.

Related Pull Requests

fetchParentPaths: jest.fn().mockResolvedValue([]),
}));

jest.mock('../files/FileTree', () => ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This mock is not quite right. This is resulting in an error being logged during the test.

Image

I recommend declaring the mocked component as a class. This needs to be done inline to the mock call do to how jest hoists definitions.

jest.mock('../files/FileTree', () => {
    // Declaring as a class since functional components do not receive refs (which FileTree does)
    class mockFileTree extends React.PureComponent {
        render() {
            return <div className="mock-file-tree" />;
        }
    }

    return {
        DEFAULT_ROOT_PREFIX: '|root',
        FileTree: mockFileTree,
    };
});

test('node not selected', () => {
const testnode = { data: { code: 'test' } };
const testFilters = new Map<string, PathModel>().set('nope', new PathModel());
const { container } = render(<FilterIcon node={testnode} filters={testFilters} />);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lint warning. I know you commonly wait to lint at the end but I wasn't sure in this case since it is all new code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, I still plan to run the linting pass right before merge

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.

2 participants