Skip to content

Commit

Permalink
🏗 Auto-format dev dashboard tests (#34546)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored May 26, 2021
1 parent 1f0bef9 commit 2ef5ed3
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 234 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ validator/export
# Files and directories explicitly ignored by eslint
build-system/babel-plugins/**/fixtures/**/*.js
build-system/babel-plugins/**/fixtures/**/*.mjs
build-system/server/app-index/test/*.js
build-system/tasks/make-extension/template/**/*
build-system/tasks/visual-diff/snippets/*.js
extensions/amp-a4a/0.1/test/testdata/**
Expand Down
16 changes: 5 additions & 11 deletions build-system/server/app-index/test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@
const {expect} = require('chai');
const {JSDOM} = require('jsdom');


const parseHtmlChunk = htmlStr => {
const {body} = (new JSDOM(htmlStr)).window.document;
const parseHtmlChunk = (htmlStr) => {
const {body} = new JSDOM(htmlStr).window.document;
expect(body.children).to.have.length(1);
return body.firstElementChild;
};


const boundAttrRe = attr =>
const boundAttrRe = (attr) =>
new RegExp(`\\[${attr}\\]=(("[^"]+")|('[^']+')|([^\\s\\>]+))`);


// JSDom doesn't parse attributes whose names don't follow the spec, so
// our only way to test [attr] values is via regex.
const getBoundAttr = ({outerHTML}, attr) => {
Expand All @@ -37,13 +34,11 @@ const getBoundAttr = ({outerHTML}, attr) => {
return;
}
const [, valuePart] = match;
if (valuePart.charAt(0) == '"' ||
valuePart.charAt(0) == '\'') {
if (valuePart.charAt(0) == '"' || valuePart.charAt(0) == "'") {
return valuePart.substring(1, valuePart.length - 1);
}
return valuePart;
}

};

const expectValidAmphtml = (validator, string) => {
const {errors: errorsAndWarnings, status} = validator.validateString(string);
Expand All @@ -55,7 +50,6 @@ const expectValidAmphtml = (validator, string) => {
expect(status).to.equal('PASS');
};


module.exports = {
expectValidAmphtml,
getBoundAttr,
Expand Down
Loading

0 comments on commit 2ef5ed3

Please sign in to comment.