<commit_before>import React      from 'react'
import ReactDOM   from 'react-dom'
import { expect } from 'chai'
import A11y       from '../src/a11y'
import rules      from '../src/rules'

describe('rules', () => {
  Object.keys(rules).forEach(function (rule) {
    describe(rule, () => {
      const {
        'default': defn
      , pass = []
      , fail = []
      } = require('../src/rules/' + rule)

      // get all messages
      const msgs = defn.reduce((acc, def) => acc.concat(def.msg), [])

      pass.forEach(function (ok) {
        it(`doesn't warn when ${ok.when}`, done => {
          const a11y = new A11y(React, ReactDOM, {
            reporter (info) {
              const {
                msg
              } = info
              expect(msgs.indexOf(msg) >= 0).to.be.true
            }
          , rules: {
              [rule]: [
                'warn'
              , ...(ok.opts || [])
              ]
            }
          })

          // force a11y into sync mode for test
          a11y.__forceSync(true)

          // create the el
          ok.render(React)<commit_msg>ensure every rule has pass, fail and description<commit_after>import React      from 'react'
import ReactDOM   from 'react-dom'
import { expect } from 'chai'
import A11y       from '../src/a11y'
import rules      from '../src/rules'

describe('rules', () => {
  Object.keys(rules).forEach(function (rule) {
    describe(rule, () => {
      const {
        'default': defn
      , pass = []
      , fail = []
      , description
      } = require('../src/rules/' + rule)

      expect(description).to.be.a.string
      expect(pass).to.have.length.above(0)
      expect(fail).to.have.length.above(0)

      // get all messages
      const msgs = defn.reduce((acc, def) => acc.concat(def.msg), [])

      pass.forEach(function (ok) {
        it(`doesn't warn when ${ok.when}`, done => {
          const a11y = new A11y(React, ReactDOM, {
            reporter (info) {
              const {
                msg
              } = info
              expect(msgs.indexOf(msg) >= 0).to.be.true
            }
          , rules: {
              [rule]: [
                'warn'
              , ...(ok.opts || [])
              ]
            }
          })

          // force a11y into sync mode for test
          a11y.__forceSync(true)

          // create the el
          ok.render(React)
{'fraction_non_alphanumeric': 0.1469970600587988, 'fraction_numerical': 0.011759764804703907, 'mean_word_length': 1.4355828220858895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3044450', 'n_tokens_mistral': 739, 'n_tokens_neox': 710, 'n_words': 158}