Skip to content

Commit

Permalink
Clean up some formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 3, 2021
1 parent 58ca179 commit d138868
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
13 changes: 5 additions & 8 deletions actions/ui-check/tests/e2e/specs/page/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ import unexpectedLinksTest from './unexpected-links';
// TODO: should we test those separately? Not all of these tests are appropriate.
let urls = [ [ '/', '?feed=rss2', '' ], ...getTestUrls() ];


const getUrlPathWithTemplate = async (urlPath) => {
const template = await page.$eval( '#template', ( el ) => el.value );
return `${ urlPath } (via: ${ getFileNameFromPath(
template
) })`
}
const getUrlPathWithTemplate = async ( urlPath ) => {
const template = await page.$eval( '#template', ( el ) => el.value );
return `${ urlPath } (via: ${ getFileNameFromPath( template ) })`;
};

// Some basic tests that apply to every page
describe.each( urls )( 'Test URL %s%s', ( url, queryString, bodyClass ) => {
Expand All @@ -36,7 +33,7 @@ describe.each( urls )( 'Test URL %s%s', ( url, queryString, bodyClass ) => {
pageResponse = await goTo( url, queryString );

try {
urlPath = await getUrlPathWithTemplate(urlPath);
urlPath = await getUrlPathWithTemplate( urlPath );
} catch ( ex ) {}
} );

Expand Down
4 changes: 3 additions & 1 deletion actions/ui-check/tests/e2e/specs/page/js-errors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ page.on( 'pageerror', ( error ) => {

export default async ( url ) => {
return errorWithMessageOnFail(
`${ url } contains javascript errors. Found ${ removeLocalPathRefs( jsError ) }`,
`${ url } contains javascript errors. Found ${ removeLocalPathRefs(
jsError
) }`,
'browser-console-should-not-contain-errors',
() => {
expect( jsError ).toBeFalsy();
Expand Down
4 changes: 2 additions & 2 deletions actions/ui-check/tests/unit/block-templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export default ( templates ) => {
! emptyInnerContentFeature( block.innerContent )
) {
failures.push(
`There's a problem with templates in: ${ templates[ i ].fileName }.`,
`There's a problem with templates in: ${ templates[ i ].fileName }.`
); // spacer

break;
break;
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions actions/ui-check/tests/utils/formatting.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ export const removeLocalPathRefs = ( str ) => {
`https?:\/\/localhost:?.*?\/.*?\/themes\/.*?\/`,
'ig'
);
const pathRegEx = new RegExp(
`\/var\/www\/html\/.*?`,
'ig'
);
const pathRegEx = new RegExp( `\/var\/www\/html\/.*?`, 'ig' );

return str.replace( urlRegEx, '' ).replace( pathRegEx, '' );
};

export const getFileNameFromPath = ( str ) => {
return /[^/]*$/.exec(str)[0];
}
return /[^/]*$/.exec( str )[ 0 ];
};

0 comments on commit d138868

Please sign in to comment.