Skip to content

Commit

Permalink
fix: Remove axe.a11yCheck()
Browse files Browse the repository at this point in the history
BREAKING CHANGE
  • Loading branch information
WilcoFiers committed Feb 10, 2018
1 parent 9c7b9f1 commit 88d039f
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 179 deletions.
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,12 @@ Installing aXe to run accessibility tests in your TypeScript project should be a
import * as axe from 'axe-core';

describe('Module', () => {
it('should have no accessibility violations', () => {
axe.a11yCheck(compiledFixture, {}, (results) => {
expect(results.violations.length).toBe(0);
});
it('should have no accessibility violations', (done) => {
axe.run(compiledFixture)
.then((results) => {
expect(results.violations.length).toBe(0);
done()
}, done);
});
});
```
Expand Down
10 changes: 0 additions & 10 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,6 @@ declare module axe {
function run(context: ElementContext, options: RunOptions): Promise<AxeResults>
function run(context: ElementContext, options: RunOptions, callback: RunCallback): void

/**
* Starts analysis on the current document and its subframes
*
* @param {Object} context The `Context` specification object @see Context
* @param {Array} options Options passed into rules or checks, temporarily modifyint them.
* @param {Function} callback The function to invoke when analysis is complete.
* @returns {Object} results The aXe results object
*/
function a11yCheck(context: ElementContext, options: {runOnly?: RunOnly, rules?: Object, iframes?: Boolean, elementRef?: Boolean, selectors?: Boolean}, callback: (results:AxeResults) => void): AxeResults

/**
* Method for configuring the data format used by aXe. Helpful for adding new
* rules, which must be registered with the library to execute.
Expand Down
9 changes: 0 additions & 9 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
1. [Results Object](#results-object)
1. [API Name: axe.registerPlugin](#api-name-axeregisterplugin)
1. [API Name: axe.cleanup](#api-name-axecleanup)
1. [API Name: axe.a11yCheck](#api-name-axea11ycheck)
1. [Virtual DOM Utilities](#virtual-dom-utilities)
1. [API Name: axe.utils.querySelectorAll](#api-name-axeutilsqueryselectorall)
1. [Common Functions](#common-functions)
Expand Down Expand Up @@ -619,14 +618,6 @@ Register a plugin with the aXe plugin system. See [implementing a plugin](plugin

Call the plugin system's cleanup function. See [implementing a plugin](plugins.md).

### API Name: axe.a11yCheck

In axe-core v1 the main method for axe was `axe.a11yCheck()`. This method was replaced with `axe.run()` in order to better deal with errors. The method `axe.a11yCheck()` differs from `axe.run()` in the following ways:

- .a11yCheck does not pass the error object to the callback, rather it returns the result as the first parameter and logs errors to the console.
- .a11yCheck requires a context object, and so will not fall back to the document root.
- .a11yCheck does not return a Promise.

### Virtual DOM Utilities

Note: If you’re writing rules or checks, you’ll have both the `node` and `virtualNode` passed in.
Expand Down
39 changes: 0 additions & 39 deletions lib/core/public/a11y-check.js

This file was deleted.

76 changes: 0 additions & 76 deletions test/core/public/a11y-check.js

This file was deleted.

8 changes: 5 additions & 3 deletions test/core/public/run-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ describe('runRules', function () {

fixture.innerHTML = '<div></div>';

axe.a11yCheck('#fixture', function (results) {
axe.run('#fixture', function (err, results) {
assert.isNull(err);
assert.lengthOf(results.incomplete, 2);
assert.equal(results.incomplete[0].id, 'incomplete-1');
assert.equal(results.incomplete[1].id, 'incomplete-2');
Expand Down Expand Up @@ -527,15 +528,16 @@ describe('runRules', function () {
});

iframeReady('../mock/frames/rule-error.html', fixture, 'context-test', function () {
axe.a11yCheck('#fixture', function (results) {
axe.run('#fixture', function (err, results) {
assert.isNull(err);
assert.lengthOf(results.incomplete, 2);
assert.equal(results.incomplete[0].id, 'incomplete-1');
assert.equal(results.incomplete[1].id, 'incomplete-2');

assert.include(results.incomplete[1].description,
'An error occured while running this rule');
done();
}, isNotCalled);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<div id="mocha"></div>
<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="a11ycheck-include-exclude.js"></script>
<script src="run-include-exclude.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*global $ */

describe('jQuery object with a11yCheck', function () {
describe('jQuery object with axe.run', function () {
'use strict';

var config = { runOnly: { type: 'rule', values: ['aria-roles'] } };

describe('include', function() {
it('should find violations', function (done) {
var target = $('#target')[0];
axe.a11yCheck({ include: [target] }, config, function (results) {
axe.run({ include: [target] }, config, function (err, results) {
assert.isNull(err);
assert.lengthOf(results.violations, 1, 'violations');
assert.lengthOf(results.passes, 0, 'passes');
done();
Expand All @@ -19,7 +20,8 @@ describe('jQuery object with a11yCheck', function () {
describe('exclude', function() {
it('should find no violations', function (done) {
var target = $('#target')[0];
axe.a11yCheck({ exclude: [target] }, config, function (results) {
axe.run({ exclude: [target] }, config, function (err, results) {
assert.isNull(err);
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 0, 'passes');
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</div>
<div id="mocha"></div>
<script src="/node_modules/jquery/dist/jquery.js"></script>
<script src="a11ycheck-object.js"></script>
<script src="run-object.js"></script>
<script src="/test/integration/adapter.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*global $ */

describe('jQuery object as a11yCheck context', function () {
describe('jQuery object as axe.run context', function () {
'use strict';
var config = { runOnly: { type: 'rule', values: ['aria-roles'] } };
it('should find no violations', function (done) {
var fixture = $('#fixture');
axe.a11yCheck(fixture, config, function (results) {
axe.run(fixture, config, function (err, results) {
assert.isNull(err);
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
done();
Expand Down
18 changes: 9 additions & 9 deletions test/integration/full/options-parameter/options-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Options parameter', function() {
describe('iframes', function() {
it('should include iframes if `iframes` is true', function(done) {
var config = { iframes: true };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -39,7 +39,7 @@ describe('Options parameter', function() {

it('should exclude iframes if `iframes` is false', function(done) {
var config = { iframes: false };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -59,7 +59,7 @@ describe('Options parameter', function() {

it('should include iframes by default', function(done) {
var config = {};
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -81,7 +81,7 @@ describe('Options parameter', function() {
describe('elementRef', function() {
it('should not return an elementRef by default', function(done) {
var config = {};
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -98,7 +98,7 @@ describe('Options parameter', function() {

it('should not return an elementRef if `elementRef` is false', function(done) {
var config = { elementRef: false };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -115,7 +115,7 @@ describe('Options parameter', function() {

it('should return element refs for the top frame only if `elementRef` is true', function(done) {
var config = { elementRef: true };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -137,7 +137,7 @@ describe('Options parameter', function() {
describe('no selectors', function() {
it('should return a selector by default', function(done) {
var config = {};
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -154,7 +154,7 @@ describe('Options parameter', function() {

it('should return a selector if `selectors` is true', function(done) {
var config = { selectors: true };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand All @@ -171,7 +171,7 @@ describe('Options parameter', function() {

it('should return no selector in top frame if `selectors` is false', function(done) {
var config = { selectors: false };
axe.a11yCheck(document, config, function(results) {
axe.run(document, config, function(err, results) {
try {
assert.lengthOf(results.violations, 0, 'violations');
assert.lengthOf(results.passes, 1, 'passes');
Expand Down
Loading

0 comments on commit 88d039f

Please sign in to comment.