{"size": 1299, "ext": "js", "max_stars_repo_path": "packages/eslint-plugin/tests/rules/require-img-alt.test.js", "max_stars_repo_name": "Plondrein/html-eslint", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/eslint-plugin/tests/rules/require-img-alt.test.js", "max_issues_repo_name": "Plondrein/html-eslint", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/eslint-plugin/tests/rules/require-img-alt.test.js", "max_forks_repo_name": "Plondrein/html-eslint", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 14.1195652174, "max_line_length": 56, "alphanum_fraction": 0.4095458045}
const createRuleTester = require("../rule-tester");
const rule = require("../../lib/rules/require-img-alt");

const ruleTester = createRuleTester();

ruleTester.run("require-img-alt", rule, {
  valid: [
    {
      code: `
<img src="./image.png" alt="image description"/>
`,
    },
    {
      code: `
<html>
  <body>
    <img src="./image.png" alt="image description">
  </body>
</html>
`,
    },
  ],
  invalid: [
    {
      code: `
<img src="./image.png"/>
`,

      errors: [
        {
          messageId: "missingAlt",
        },
      ],
    },
    {
      code: `
<html>
  <body>
    <img src="./image.png">
  </body>
</html>
`,

      errors: [
        {
          messageId: "missingAlt",
          line: 4,
          column: 6,
          endColumn: 29,
          endLine: 4,
        },
      ],
    },
    {
      code: `
<html>
  <body>
    <img src="./image.png" alt="">
  </body>
</html>
`,

      errors: [
        {
          messageId: "missingAlt",
          line: 4,
          column: 6,
          endColumn: 36,
          endLine: 4,
        },
      ],
    },
    {
      code: `
<html>
  <body>
     <div>
        <img src="./image.png" alt="">
     </div>
  </body>
</html>
`,

      errors: [
        {
          messageId: "missingAlt",
        },
      ],
    },
  ],
});
