Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test ensuring locale data is valid #1660

Closed
stephenmathieson opened this issue Jun 27, 2019 · 0 comments · Fixed by #1673
Closed

Add a test ensuring locale data is valid #1660

stephenmathieson opened this issue Jun 27, 2019 · 0 comments · Fixed by #1673
Assignees
Labels
core Issues in the core code (lib/core) feat New feature or enhancement

Comments

@stephenmathieson
Copy link
Member

Expectation: We should know that our locale files (./locales/*.json) are valid in order to prevent issues like #1127. This should be verified by a computer (CircleCI) on every release (or every commit?), not just done manually.

Actual: We do not test locale data.

Motivation: axe-core throws when given "bad" locale data.

An example test may look like:

const fs = require('fs')
const path = require('path')
const assert = require('assert')
const glob = require('glob')

const localeFiles = glob.sync('./locales/*.json')

describe('locales', () => {
  for (const localeFile of localeFiles) {
    describe(`locale ${localeFile}`, () => {
      it('should be valid', () => {
        const localeData = fs.readFileSync(path.join(__dirname, localeFile), 'utf-8')
        const locale = JSON.parse(localeData)
        assert.doesNotThrow(() => axe.configure({ locale }) )
      })
    })
  }
})
@straker straker added core Issues in the core code (lib/core) feat New feature or enhancement labels Jul 1, 2019
@straker straker self-assigned this Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues in the core code (lib/core) feat New feature or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants