Skip to content
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

🏗 Auto-format dev dashboard tests #34546

Merged
merged 1 commit into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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