Skip to content

Commit

Permalink
test: disable es6 syntax usage within tests directory (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeyyy authored May 15, 2019
1 parent 3726901 commit 9b13508
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 43 deletions.
6 changes: 5 additions & 1 deletion test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": ["prettier"],
"parserOptions":{
"ecmaVersion": 5
},
"env": {
"browser": true
"browser": true,
"es6": false
},
"globals": {
"describe": true,
Expand Down
8 changes: 4 additions & 4 deletions test/checks/lists/dlitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('dlitem', function() {
});

it('returns true if the dd/dt is in a div with a dl as grandparent', function() {
const nodeNames = ['dd', 'dt'];
var nodeNames = ['dd', 'dt'];
nodeNames.forEach(function(nodeName) {
var checkArgs = checkSetup(
'<dl><div><' +
Expand All @@ -80,7 +80,7 @@ describe('dlitem', function() {
});

it('returns false if the dd/dt is in a div with a role with a dl as grandparent with a list role', function() {
const nodeNames = ['dd', 'dt'];
var nodeNames = ['dd', 'dt'];
nodeNames.forEach(function(nodeName) {
var checkArgs = checkSetup(
'<dl><div role="list"><' +
Expand All @@ -94,7 +94,7 @@ describe('dlitem', function() {
});

it('returns false if the dd/dt is in a div[role=presentation] with a dl as grandparent', function() {
const nodeNames = ['dd', 'dt'];
var nodeNames = ['dd', 'dt'];
nodeNames.forEach(function(nodeName) {
var checkArgs = checkSetup(
'<dl><div role="presentation"><' +
Expand All @@ -108,7 +108,7 @@ describe('dlitem', function() {
});

it('returns false if the dd/dt is in a div[role=none] with a dl as grandparent', function() {
const nodeNames = ['dd', 'dt'];
var nodeNames = ['dd', 'dt'];
nodeNames.forEach(function(nodeName) {
var checkArgs = checkSetup(
'<dl><div role="none"><' +
Expand Down
5 changes: 3 additions & 2 deletions test/checks/mobile/css-orientation-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('css-orientation-lock tests', function() {
'Dynamic document for CSS Orientation Lock tests'
);
var isIE11 = axe.testUtils.isIE11;
var isPhantom = window.PHANTOMJS ? true : false;

afterEach(function() {
checks['css-orientation-lock'] = origCheck;
Expand All @@ -30,7 +31,7 @@ describe('css-orientation-lock tests', function() {
};

function getSheet(data) {
const style = dynamicDoc.createElement('style');
var style = dynamicDoc.createElement('style');
style.type = 'text/css';
style.appendChild(dynamicDoc.createTextNode(data));
dynamicDoc.head.appendChild(style);
Expand Down Expand Up @@ -220,7 +221,7 @@ describe('css-orientation-lock tests', function() {
});

// This currently breaks in IE11
(isIE11 ? it.skip : it)(
(isIE11 || isPhantom ? it.skip : it)(
'returns false if TRANSFORM style applied is ROTATE, and is divisible by 90 and not divisible by 180',
function() {
var actual = checks['css-orientation-lock'].evaluate.call(
Expand Down
2 changes: 1 addition & 1 deletion test/commons/aria/arialabel-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('aria.arialabelText', function() {
var node = document.createElement('div');
var label = ' my label ';
node.setAttribute('aria-label', label);
const vNode = { actualNode: node };
var vNode = { actualNode: node };
assert.equal(aria.arialabelText(vNode), label);
});

Expand Down
14 changes: 7 additions & 7 deletions test/commons/aria/is-aria-role-allowed-on-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ describe('aria.isAriaRoleAllowedOnElement', function() {
it('returns false, ensure evaluateRoleForElement in lookupTable is invoked', function() {
var overrideInvoked = false;
axe.commons.aria.lookupTable.evaluateRoleForElement = {
IMG: ({ node, out }) => {
IMG: function(options) {
overrideInvoked = true;
assert.isDefined(node);
assert.equal(node.nodeName.toUpperCase(), 'IMG');
assert.isBoolean(out);
assert.isDefined(options.node);
assert.equal(options.node.nodeName.toUpperCase(), 'IMG');
assert.isBoolean(options.out);
return false;
}
};
Expand All @@ -261,10 +261,10 @@ describe('aria.isAriaRoleAllowedOnElement', function() {
it('returns false if element with role MENU type context', function() {
var overrideInvoked = false;
axe.commons.aria.lookupTable.evaluateRoleForElement = {
LI: ({ node }) => {
LI: function(options) {
overrideInvoked = true;
assert.isDefined(node);
assert.equal(node.nodeName.toUpperCase(), 'LI');
assert.isDefined(options.node);
assert.equal(options.node.nodeName.toUpperCase(), 'LI');
return false;
}
};
Expand Down
6 changes: 3 additions & 3 deletions test/commons/matches/from-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('matches.fromDefinition', function() {

it('matches a definition with a `nodeName` property', function() {
fixture.innerHTML = '<div>foo</div>';
const matchers = [
var matchers = [
'div',
['div', 'span'],
/div/,
Expand All @@ -37,7 +37,7 @@ describe('matches.fromDefinition', function() {

it('matches a definition with an `attributes` property', function() {
fixture.innerHTML = '<div foo="bar">foo</div>';
const matchers = [
var matchers = [
'bar',
['bar', 'baz'],
/bar/,
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('matches.fromDefinition', function() {

it('matches a definition with a `properties` property', function() {
fixture.innerHTML = '<input />';
const matchers = [
var matchers = [
'text',
['text', 'password'],
/text/,
Expand Down
2 changes: 1 addition & 1 deletion test/commons/matches/node-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('matches.nodeName', function() {

it('works with virtual nodes', function() {
fixture.innerHTML = '<h1>foo</h1>';
const virtualNode = { actualNode: fixture.firstChild };
var virtualNode = { actualNode: fixture.firstChild };
assert.isTrue(matchNodeName(virtualNode, 'h1'));
assert.isFalse(matchNodeName(virtualNode, 'div'));
});
Expand Down
2 changes: 1 addition & 1 deletion test/core/base/audit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*global Audit, Rule */
/*global Audit, Rule, Promise */
describe('Audit', function() {
'use strict';

Expand Down
2 changes: 1 addition & 1 deletion test/core/reporters/raw-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('reporters - raw-env', function() {
var mockResults;
var orig;
var rawResults;
const env = helpers.getEnvironmentData();

before(function() {
mockResults = [
Expand Down Expand Up @@ -134,6 +133,7 @@ describe('reporters - raw-env', function() {
if (err) {
return done(err);
}
var env = helpers.getEnvironmentData();
assert.deepEqual(results.raw, rawResults);
assert.deepEqual(results.env, env);
done();
Expand Down
8 changes: 4 additions & 4 deletions test/core/utils/get-stylesheet-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ describe('axe.utils.getStyleSheetFactory', function() {
});

it('returns a function when passed argument of dynamicDocument', function() {
const actual = axe.utils.getStyleSheetFactory(dynamicDoc);
var actual = axe.utils.getStyleSheetFactory(dynamicDoc);
assert.isFunction(actual);
});

it('returns a CSSOM stylesheet, when invoked with data (text)', function() {
const stylesheetFactory = axe.utils.getStyleSheetFactory(dynamicDoc);
const actual = stylesheetFactory({
data: `.someStyle{background-color:red;}`,
var stylesheetFactory = axe.utils.getStyleSheetFactory(dynamicDoc);
var actual = stylesheetFactory({
data: '.someStyle{background-color:red;}',
root: document,
priority: [1, 0]
});
Expand Down
6 changes: 3 additions & 3 deletions test/core/utils/parse-crossorigin-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('axe.utils.parseCrossOriginStylesheet', function() {
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet,
convertDataToStylesheet: convertDataToStylesheet,
rootIndex: 1
};
var priority = [1, 0];
Expand Down Expand Up @@ -61,13 +61,13 @@ describe('axe.utils.parseCrossOriginStylesheet', function() {
});
});

it(`rejects when given url to fetch is not found`, function(done) {
it('rejects when given url to fetch is not found', function(done) {
var importUrl =
'https://make-up-a-website-that-does-not-exist.com/style.css';
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet,
convertDataToStylesheet: convertDataToStylesheet,
rootIndex: 1
};
var priority = [1, 0];
Expand Down
6 changes: 3 additions & 3 deletions test/core/utils/parse-sameorigin-stylesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('axe.utils.parseSameOriginStylesheet', function() {
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet
convertDataToStylesheet: convertDataToStylesheet
};
var priority = [1, 0];
var importedUrls = [];
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('axe.utils.parseSameOriginStylesheet', function() {
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet
convertDataToStylesheet: convertDataToStylesheet
};
var priority = [1, 0];
var importedUrls = [];
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('axe.utils.parseSameOriginStylesheet', function() {
var options = {
rootNode: document,
shadowId: undefined,
convertDataToStylesheet
convertDataToStylesheet: convertDataToStylesheet
};
var priority = [1, 0];
var importedUrls = [];
Expand Down
8 changes: 4 additions & 4 deletions test/core/utils/preload-cssom.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('axe.utils.preloadCssom', function() {
});

it('returns CSSOM object containing an array of sheets', function(done) {
var actual = axe.utils.preloadCssom({ treeRoot });
var actual = axe.utils.preloadCssom({ treeRoot: treeRoot });
actual
.then(function(cssom) {
assert.isAtLeast(cssom.length, 2);
Expand All @@ -48,7 +48,7 @@ describe('axe.utils.preloadCssom', function() {
});

it('returns CSSOM and ensure that each object have defined properties', function(done) {
var actual = axe.utils.preloadCssom({ treeRoot });
var actual = axe.utils.preloadCssom({ treeRoot: treeRoot });
actual
.then(function(cssom) {
assert.isAtLeast(cssom.length, 2);
Expand All @@ -69,7 +69,7 @@ describe('axe.utils.preloadCssom', function() {
});

it('returns false if number of sheets returned does not match stylesheets defined in document', function(done) {
var actual = axe.utils.preloadCssom({ treeRoot });
var actual = axe.utils.preloadCssom({ treeRoot: treeRoot });
actual
.then(function(cssom) {
assert.isFalse(cssom.length <= 1);
Expand All @@ -81,7 +81,7 @@ describe('axe.utils.preloadCssom', function() {
});

it('returns all stylesheets and ensure each sheet has property cssRules', function(done) {
var actual = axe.utils.preloadCssom({ treeRoot });
var actual = axe.utils.preloadCssom({ treeRoot: treeRoot });
actual
.then(function(cssom) {
cssom.forEach(function(s) {
Expand Down
10 changes: 5 additions & 5 deletions test/integration/full/preload-cssom/preload-cssom.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ describe('preload cssom integration test', function() {
}

function getPreloadCssom(root) {
const treeRoot = axe.utils.getFlattenedTree(root ? root : document);
return axe.utils.preloadCssom({ treeRoot });
var treeRoot = axe.utils.getFlattenedTree(root ? root : document);
return axe.utils.preloadCssom({ treeRoot: treeRoot });
}

function commonTestsForRootNodeAndNestedFrame(root) {
it('returns cross-origin stylesheet', function(done) {
stylesForPage = [styleSheets.crossOriginLinkHref];
attachStylesheets(
{
root,
root: root,
styles: stylesForPage
},
function(err) {
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('preload cssom integration test', function() {
stylesForPage = [styleSheets.crossOriginLinkHrefMediaPrint];
attachStylesheets(
{
root,
root: root,
styles: stylesForPage
},
function(err) {
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('preload cssom integration test', function() {
];
attachStylesheets(
{
root,
root: root,
styles: stylesForPage
},
function(err) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/full/preload/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('axe.utils.preload integration test', function() {
return axe.utils.preload({
preload: {
assets: ['cssom'],
timeout
timeout: timeout
}
});
}
Expand Down
1 change: 1 addition & 0 deletions test/integration/full/umd/umd-window.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*global Promise */
describe('UMD window', function() {
'use strict';

Expand Down
1 change: 0 additions & 1 deletion test/integration/rules/runner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
ui: 'bdd'
});
var assert = chai.assert;
var global = {};
</script>
<% files.forEach(function (file) { %>
<script src="../../<%=file%>"></script>
Expand Down
1 change: 0 additions & 1 deletion test/runner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
ui: 'bdd'
});
var assert = chai.assert;
var global = {};
</script>
<% files.forEach(function (file) { %>
<script src="/<%=file%>"></script>
Expand Down

0 comments on commit 9b13508

Please sign in to comment.