Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b0a1157
Merge remote-tracking branch 'upstream/v4' into no-node-access
thebinaryfelix Jun 28, 2020
9ebf44e
refactor(utils): add properties and methods
thebinaryfelix Jun 28, 2020
4d41edc
test(no-node-access): add first scenarios
thebinaryfelix Jun 28, 2020
9ebf3d2
feat(no-node-access): add rule
thebinaryfelix Jun 28, 2020
cba1f13
test(no-node-access): add scenarios
thebinaryfelix Jun 28, 2020
5092889
refactor(no-node-access): simplify conditions
thebinaryfelix Jun 29, 2020
f63f2b0
refactor(no-node-access): add scenario
thebinaryfelix Jun 29, 2020
c1ecd66
refactor(no-node-access): remove conditional
thebinaryfelix Jun 29, 2020
934bc1d
refactor(utils): add DOM properties
thebinaryfelix Jun 29, 2020
70a366e
refactor(no-node-access): add scenario
thebinaryfelix Jun 29, 2020
291eddf
docs(no-node-access): add readme
thebinaryfelix Jun 29, 2020
e3328ee
refactor(utils): export const
thebinaryfelix Jun 29, 2020
6cc5648
docs(no-node-access): fix file location
thebinaryfelix Jun 29, 2020
af0ed98
docs(readme): add no-node-access
thebinaryfelix Jun 29, 2020
8f545d1
refactor(no-node-access): change highlight location
thebinaryfelix Jun 29, 2020
145a89b
docs(no-node-access): fix typo
thebinaryfelix Jun 29, 2020
bd13e95
refactor(utils): add missing property
thebinaryfelix Jun 29, 2020
f5eacca
refactor(no-node-access): simplify checks
thebinaryfelix Jul 3, 2020
9415c3b
test(no-node-access): add more scenarios
thebinaryfelix Jul 3, 2020
0f1cd36
docs(no-node-access): update examples
thebinaryfelix Jul 3, 2020
ba40a64
Merge branch 'v4' of https://github.com/testing-library/eslint-plugin…
thebinaryfelix Jul 3, 2020
9d4f356
refactor(no-node-access): narrow error cases
thebinaryfelix Jul 5, 2020
ecb12fe
refactor(no-node-access): check imports
thebinaryfelix Jul 10, 2020
eb8d4a3
refactor(no-node-access): rename variable
thebinaryfelix Jul 10, 2020
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(no-node-access): add first scenarios
  • Loading branch information
thebinaryfelix committed Jun 28, 2020
commit 4d41edca3c66ceb6ecfa23ade1ce7f522fa05178
53 changes: 53 additions & 0 deletions tests/lib/rules/no-node-access.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { createRuleTester } from '../test-utils';
import rule, { RULE_NAME } from '../../../lib/rules/no-node-access';

const ruleTester = createRuleTester({
ecmaFeatures: {
jsx: true,
},
});

ruleTester.run(RULE_NAME, rule, {
valid: [
{
code: `
const buttonText = screen.getByText('submit');
`,
},
{
code: `
const obj = {
firstChild: <div>child</div>
}
obj.firstChild
`,
},
],
invalid: [
{
code: `
function getExampleDOM() {
const container = document.createElement('div');
container.innerHTML = \`
<label for="username">Username</label>
<input id="username" />
<button>Print Username</button>
<label for="password">Password</label>
<input id="password" />
<button>Print password</button>
<button type="submit">Submit</button>
\`;
return container;
}
const exampleDOM = getExampleDOM();
const buttons = screen.getAllByRole(exampleDOM, 'button');
const buttonText = buttons[1].firstChild
`,
errors: [
{
messageId: 'noNodeAccess',
},
],
},
],
});