Skip to content

Commit

Permalink
fix(audit): updated axe.reset() to reset branding, application, and t…
Browse files Browse the repository at this point in the history
…agExcludes. (dequelabs#2537)

* Moved brand, application, and tagExclude setting to Init.

This way when reset is called they will also be rest.

* Added the tests for brand and application.

* Finished the test for tagExclude.

* Updated the code to check for arrays to be equal.

* Updated for checking if arrays are equal.

* Fixed the tagExclude test case.
  • Loading branch information
Bracciata authored Oct 5, 2020
1 parent da4dd44 commit 828864b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ const mergeFallbackMessage = (a, b) => {
class Audit {
constructor(audit) {
// defaults
this.brand = 'axe';
this.application = 'axeAPI';
this.tagExclude = ['experimental'];
this.lang = 'en';
this.defaultConfig = audit;
this.standards = standards;
Expand Down Expand Up @@ -298,6 +295,9 @@ class Audit {
this.commands = {};
this.rules = [];
this.checks = {};
this.brand = 'axe';
this.application = 'axeAPI';
this.tagExclude = ['experimental'];
unpackToObject(audit.rules, this, 'addRule');
unpackToObject(audit.checks, this, 'addCheck');
this.data = {};
Expand Down
29 changes: 29 additions & 0 deletions test/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,35 @@ describe('Audit', function() {
audit.resetRulesAndChecks();
assert.equal(audit.lang, 'en');
});
it('should reset brand', function() {
var audit = new Audit();
assert.equal(audit.brand, 'axe');
audit.setBranding({
brand: 'test'
});
assert.equal(audit.brand, 'test');
audit.resetRulesAndChecks();
assert.equal(audit.brand, 'axe');
});
it('should reset brand application', function() {
var audit = new Audit();
assert.equal(audit.application, 'axeAPI');
audit.setBranding({
application: 'test'
});
assert.equal(audit.application, 'test');
audit.resetRulesAndChecks();
assert.equal(audit.application, 'axeAPI');
});
it('should reset brand tagExlcude', function() {
axe._load({});
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
axe.configure({
tagExclude: ['ninjas']
});
axe._audit.resetRulesAndChecks();
assert.deepEqual(axe._audit.tagExclude, ['experimental']);
});
});

describe('Audit#addCheck', function() {
Expand Down

0 comments on commit 828864b

Please sign in to comment.