diff --git a/test/.jshintrc b/test/.jshintrc index dce6c75bef..d8372a2fbc 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -3,6 +3,7 @@ "globals": { "describe": true, "it": true, + "xit": true, "before": true, "beforeEach": true, "after": true, diff --git a/test/testutils.js b/test/testutils.js index d7cab92b85..07508a5b33 100644 --- a/test/testutils.js +++ b/test/testutils.js @@ -16,4 +16,35 @@ testUtils.shadowSupport = (function(document) { })(document); +testUtils.fixtureSetup = function (content) { + 'use strict'; + var fixture = document.querySelector('#fixture'); + if (typeof content === 'string') { + fixture.innerHTML = content; + } else if (content instanceof Node) { + fixture.appendChild(content); + } + axe._tree = axe.utils.getFlattenedTree(fixture); + return fixture; +}; + +/** + * Create check arguments + * + * @param Node|String Stuff to go into the fixture (html or node) + * @param Object Options argument for the check (optional, default: {}) + * @param String Target for the check, CSS selector (default: '#target') + */ +testUtils.checkSetup = function (content, options, target) { + 'use strict'; + // Normalize the params + if (typeof options !== 'object') { + target = options; + options = {}; + } + testUtils.fixtureSetup(content); + var node = axe.utils.querySelectorAll(axe._tree[0], target || '#target')[0]; + return [node.actualNode, options, node]; +}; + axe.testUtils = testUtils; \ No newline at end of file