Skip to content

Commit 81edb3e

Browse files
committed
fix(no-node-access): document more valid test cases
These examples were gotten from discussions in issue #386
1 parent e31fe03 commit 81edb3e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/lib/rules/no-node-access.test.ts

+38
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,44 @@ ruleTester.run(RULE_NAME, rule, {
138138
expect(container.firstChild).toMatchSnapshot()
139139
`,
140140
},
141+
{
142+
// Example from discussions in issue #386
143+
code: `
144+
import { render } from '@testing-library/react';
145+
146+
function Wrapper(props) {
147+
// this should NOT be reported
148+
if (props.children) {
149+
// ...
150+
}
151+
152+
// this should NOT be reported
153+
return <div className="wrapper-class">{props.children}</div>
154+
};
155+
156+
render(<Wrapper><SomeComponent /></Wrapper>);
157+
expect(screen.getByText('SomeComponent')).toBeInTheDocument();
158+
`,
159+
},
160+
{
161+
// Example from discussions in issue #386
162+
code: `
163+
import { render } from '@testing-library/react';
164+
165+
function Wrapper({ children }) {
166+
// this should NOT be reported
167+
if (children) {
168+
// ...
169+
}
170+
171+
// this should NOT be reported
172+
return <div className="wrapper-class">{children}</div>
173+
};
174+
175+
render(<Wrapper><SomeComponent /></Wrapper>);
176+
expect(screen.getByText('SomeComponent')).toBeInTheDocument();
177+
`,
178+
},
141179
]
142180
),
143181
invalid: SUPPORTED_TESTING_FRAMEWORKS.flatMap((testingFramework) => [

0 commit comments

Comments
 (0)