Skip to content

Commit

Permalink
test: ensure locale files are valid (#1673)
Browse files Browse the repository at this point in the history
* test: test that locale files are valid

* relative paths from file

* build before testing

* make sync
  • Loading branch information
straker authored Jul 9, 2019
1 parent 8514516 commit 588f9b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ jobs:
- <<: *restore_dependency_cache
- run: npm run test:examples

# Test locale files
test_locales:
<<: *defaults
steps:
- checkout
- <<: *restore_dependency_cache
- run: npm run build
- run: npm run test:locales

# Release a "next" version
next_release:
<<: *defaults
Expand Down Expand Up @@ -117,12 +126,16 @@ workflows:
- test_examples:
requires:
- test
- test_locales:
requires:
- test
# Hold for approval
- hold:
type: approval
requires:
- test
- test_examples
- test_locales
filters:
branches:
only:
Expand All @@ -133,6 +146,7 @@ workflows:
- dependencies
- test
- test_examples
- test_locales
filters:
branches:
only: develop
Expand All @@ -142,6 +156,7 @@ workflows:
- dependencies
- test
- test_examples
- test_locales
- hold
filters:
branches:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"eslint": "eslint --color --format stylish '{lib,test,build,doc}/**/*.js' 'Gruntfile.js'",
"test": "npm run retire && tsc && grunt test",
"test:examples": "node ./doc/examples/test-examples",
"test:locales": "mocha test/test-locales.js",
"version": "echo \"use 'npm run release' to bump axe-core version\" && exit 1",
"prepublishOnly": "grunt build && grunt file-exists",
"retire": "retire --jspath lib --nodepath ./ --ignorefile .retireignore.json --severity medium",
Expand Down
22 changes: 22 additions & 0 deletions test/test-locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var fs = require('fs');
var path = require('path');
var assert = require('assert');
var glob = require('glob');
var axe = require(path.join(__dirname, '../axe'));

var localeFiles = glob.sync(path.join(__dirname, '../locales/*.json'));

describe('locales', function() {
localeFiles.forEach(function(localeFile) {
var localeName = path.basename(localeFile);
it(localeName + ' should be valid', function() {
var localeData = fs.readFileSync(localeFile, 'utf-8');
var locale = JSON.parse(localeData);
function fn() {
axe.configure({ locale: locale });
}

assert.doesNotThrow(fn);
});
});
});

0 comments on commit 588f9b5

Please sign in to comment.