Skip to content

Commit

Permalink
test: add test for prefer-docusaurus-heading rule
Browse files Browse the repository at this point in the history
Signed-off-by: Devansu <[email protected]>
  • Loading branch information
Devansu-Yadav committed Jan 5, 2023
1 parent f3f6b6c commit 531e764
Showing 1 changed file with 69 additions and 0 deletions.
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,
},
],
});

0 comments on commit 531e764

Please sign in to comment.