Skip to content

Commit

Permalink
DqElement in checkHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Aug 15, 2023
1 parent d1b07e1 commit c59ad63
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/core/utils/check-helper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toArray from './to-array';
import nodeSerializer from './node-serializer';
import DqElement from './dq-element';
import AbstractVirtualNode from '../base/virtual-node/abstract-virtual-node';

/**
Expand Down Expand Up @@ -43,7 +43,7 @@ function checkHelper(checkResult, options, resolve, reject) {
node = node.actualNode;
}
if (node instanceof window.Node) {
const nodeSpec = nodeSerializer.toSpec(node);
const nodeSpec = new DqElement(node);
checkResult.relatedNodes.push(nodeSpec);
}
});
Expand Down
8 changes: 8 additions & 0 deletions test/core/utils/check-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ describe('axe.utils.checkHelper', () => {
const fixture = document.getElementById('fixture');
const getSelector = node => node.selector;

it('returns DqElements', () => {
fixtureSetup('<div id="t1"></div><div id="t2"></div>');
const target = {};
const helper = axe.utils.checkHelper(target, noop);
helper.relatedNodes(fixture.children);
assert.instanceOf(target.relatedNodes[0], axe.utils.DqElement);
});

it('should accept NodeList', () => {
fixtureSetup('<div id="t1"></div><div id="t2"></div>');
const target = {};
Expand Down
2 changes: 1 addition & 1 deletion test/core/utils/node-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('nodeSerializer', () => {
});
});

it('returns selector if fromFame, even if runOptions.selectors is false', () => {
it('returns selector if fromFrame, even if runOptions.selectors is false', () => {
const dqElm = new DqElement(fixture);
dqElm.fromFrame = true;
const spec = nodeSerializer.dqElmToSpec(dqElm, {
Expand Down

0 comments on commit c59ad63

Please sign in to comment.