-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for prefer-docusaurus-heading rule
Signed-off-by: Devansu <[email protected]>
- Loading branch information
1 parent
f3f6b6c
commit 531e764
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
packages/eslint-plugin/src/rules/__tests__/prefer-docusaurus-heading.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import rule from '../prefer-docusaurus-heading'; | ||
import {RuleTester} from './testUtils'; | ||
|
||
const errorsJSX = [{messageId: 'headings'}] as const; | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
}); | ||
|
||
ruleTester.run('prefer-docusaurus-heading', rule, { | ||
valid: [ | ||
{ | ||
code: "<Heading as='h1'>heading 1</Heading>", | ||
}, | ||
{ | ||
code: "<Heading as='h2'>heading 2</Heading>", | ||
}, | ||
{ | ||
code: "<Heading as='h3'>heading 3</Heading>", | ||
}, | ||
{ | ||
code: "<Heading as='h4'>heading 4</Heading>", | ||
}, | ||
{ | ||
code: "<Heading as='h5'>heading 5</Heading>", | ||
}, | ||
{ | ||
code: "<Heading as='h6'>heading 6</Heading>", | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: '<h1>heading 1</h1>', | ||
errors: errorsJSX, | ||
}, | ||
{ | ||
code: '<h2>heading 2</h2>', | ||
errors: errorsJSX, | ||
}, | ||
{ | ||
code: '<h3>heading 3</h3>', | ||
errors: errorsJSX, | ||
}, | ||
{ | ||
code: '<h4>heading 4</h4>', | ||
errors: errorsJSX, | ||
}, | ||
{ | ||
code: '<h5>heading 5</h5>', | ||
errors: errorsJSX, | ||
}, | ||
{ | ||
code: '<h6>heading 6</h6>', | ||
errors: errorsJSX, | ||
}, | ||
], | ||
}); |