-
Notifications
You must be signed in to change notification settings - Fork 788
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
perf(reporter): add option to limit result types to be processed #568
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
|
||
describe('helpers.processAggregate', function () { | ||
'use strict'; | ||
var results, options; | ||
|
||
beforeEach(function () { | ||
results = [{ | ||
id: 'passed-rule', | ||
passes: [{ | ||
result: 'passed', | ||
node: { | ||
element: document.createElement('div'), | ||
selector: 'header > .thing', | ||
source: '<div class=\"thing\">Thing</div>', | ||
xpath: '/header/div[@class="thing"]' | ||
}, | ||
any: [{ | ||
id: 'passed-rule', | ||
relatedNodes: [{ | ||
element: document.createElement('div'), | ||
selector: 'footer > .thing', | ||
source: '<div class=\"thing\">Thing</div>', | ||
xpath: '/footer/div[@class="thing"]', | ||
}] | ||
}], | ||
all: [], | ||
none: [] | ||
}], | ||
inapplicable: [], | ||
incomplete: [], | ||
violations: [] | ||
}, { | ||
id: 'failed-rule', | ||
violations: [{ | ||
result: 'failed', | ||
node: { | ||
selector: '#dopel', | ||
source: '<input id=\"dopel\"/>', | ||
xpath: '/main/input[@id="dopel"]', | ||
fromFrame: true | ||
}, | ||
any: [{ | ||
id: 'failed-rule', | ||
relatedNodes: [{ | ||
element: document.createElement('input'), | ||
selector: '#dopel', | ||
source: '<input id=\"dopel\"/>', | ||
xpath: '/main/input[@id="dopel"]', | ||
fromFrame: true | ||
}] | ||
}], | ||
all: [], | ||
none: [] | ||
}], | ||
inapplicable: [], | ||
passes: [], | ||
incomplete: [] | ||
}]; | ||
}); | ||
|
||
it('should add a `timestamp` property to the `resultObject`', function () { | ||
var resultObject = helpers.processAggregate(results, {}); | ||
assert.isDefined(resultObject.timestamp); | ||
}); | ||
|
||
it('should add a `url` property to the `resultObject`', function () { | ||
var resultObject = helpers.processAggregate(results, {}); | ||
assert.isDefined(resultObject.url); | ||
}); | ||
|
||
it('should remove the `result` property from each node in each ruleResult', function () { | ||
assert.isDefined(results.find(function (r) { | ||
return r.id === 'passed-rule'; | ||
}).passes[0].result); | ||
|
||
var resultObject = helpers.processAggregate(results, {}); | ||
var ruleResult = resultObject.passes.find(function (r) { | ||
return r.id === 'passed-rule'; | ||
}); | ||
assert.isUndefined(ruleResult.nodes[0].result); | ||
}); | ||
|
||
it('should remove the `node` property from each node in each ruleResult', function () { | ||
assert.isDefined(results.find(function (r) { | ||
return r.id === 'passed-rule'; | ||
}).passes[0].node); | ||
|
||
var resultObject = helpers.processAggregate(results, {}); | ||
var ruleResult = resultObject.passes.find(function (r) { | ||
return r.id === 'passed-rule'; | ||
}); | ||
assert.isUndefined(ruleResult.nodes[0].node); | ||
}); | ||
|
||
describe('`options` argument', function () { | ||
|
||
describe('`resultTypes` option', function () { | ||
|
||
it('should remove non-specified result types from the `resultObject`', function () { | ||
var resultObject = helpers.processAggregate(results, { resultTypes: ['passes', 'violations'] }); | ||
assert.isDefined(resultObject.passes); | ||
assert.isDefined(resultObject.violations); | ||
assert.isUndefined(resultObject.incomplete); | ||
assert.isUndefined(resultObject.inapplicable); | ||
}); | ||
}); | ||
|
||
describe('`elementRef` option', function () { | ||
|
||
describe('when set to true', function () { | ||
|
||
before(function () { | ||
options = { elementRef: true }; | ||
}); | ||
|
||
describe('when node\'s, or relatedNode\'s, `fromFrame` equals false', function () { | ||
it('should add an `element` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isDefined(resultObject.passes[0].nodes[0].element); | ||
assert.isDefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].element); | ||
}); | ||
}); | ||
|
||
describe('when node\'s, or relatedNode\'s, `fromFrame` equals true', function () { | ||
it('should NOT add an `element` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].element); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].any[0].relatedNodes[0].element); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when set to false', function () { | ||
|
||
before(function () { | ||
options = { elementRef: false }; | ||
}); | ||
|
||
it('should NOT add an `element` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].element); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].element); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].element); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].any[0].relatedNodes[0].element); | ||
}); | ||
}); | ||
|
||
describe('when not set at all', function () { | ||
|
||
it('should NOT add an `element` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, {}); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].element); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].element); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].element); | ||
assert.isUndefined(resultObject.violations[0].nodes[0].any[0].relatedNodes[0].element); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('`selectors` option', function () { | ||
|
||
describe('when set to false', function () { | ||
|
||
before(function () { | ||
options = { selectors: false }; | ||
}); | ||
|
||
describe('when node\'s, or relatedNode\'s, `fromFrame` equals true', function () { | ||
it('should add a `target` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isDefined(resultObject.violations[0].nodes[0].target); | ||
assert.isDefined(resultObject.violations[0].nodes[0].any[0].relatedNodes[0].target); | ||
}); | ||
}); | ||
|
||
describe('when node\'s, or relatedNode\'s, `fromFrame` equals false', function () { | ||
it('should NOT add a `target` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].target); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].target); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when set to true', function () { | ||
|
||
before(function () { | ||
options = { selectors: true }; | ||
}); | ||
|
||
it('should add a `target` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isDefined(resultObject.passes[0].nodes[0].target); | ||
assert.isDefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].target); | ||
}); | ||
}); | ||
|
||
describe('when not set at all', function () { | ||
|
||
it('should add a `target` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, {}); | ||
assert.isDefined(resultObject.passes[0].nodes[0].target); | ||
assert.isDefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].target); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('`xpath` option', function () { | ||
|
||
describe('when set to true', function () { | ||
|
||
before(function () { | ||
options = { xpath: true }; | ||
}); | ||
|
||
it('should add an `xpath` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isDefined(resultObject.passes[0].nodes[0].xpath); | ||
assert.isDefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].xpath); | ||
}); | ||
}); | ||
|
||
describe('when set to false', function () { | ||
|
||
before(function () { | ||
options = { xpath: false }; | ||
}); | ||
|
||
it('should NOT add an `xpath` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, options); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].xpath); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].xpath); | ||
}); | ||
}); | ||
|
||
describe('when not set at all', function () { | ||
|
||
it('should NOT add an `xpath` property to the subResult nodes or relatedNodes', function () { | ||
var resultObject = helpers.processAggregate(results, {}); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].xpath); | ||
assert.isUndefined(resultObject.passes[0].nodes[0].any[0].relatedNodes[0].xpath); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for
axe.configure
is above, not below, and the internal link is invalid. I figured we ought to simply remove this.