Skip to content

Commit

Permalink
Fixture regeneration: Infer tabs use from prettier config (#30813)
Browse files Browse the repository at this point in the history
* Fixture Regeneration: Use tabs

* Fixture regeneration: Infer tabs use from prettier config
  • Loading branch information
ockham authored Apr 14, 2021
1 parent 98c089e commit 2190665
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions test/integration/full-content/full-content.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
registerCoreBlocks,
__experimentalRegisterExperimentalCoreBlocks,
} from '@wordpress/block-library';
import prettierConfig from '@wordpress/prettier-config';
//eslint-disable-next-line no-restricted-syntax
import {
blockNameToFixtureBasename,
Expand Down Expand Up @@ -75,6 +76,13 @@ describe( 'full post content fixture', () => {
}
} );

let spacer = 4;
if ( prettierConfig?.useTabs ) {
spacer = '\t';
} else if ( prettierConfig?.tabWidth ) {
spacer = prettierConfig?.tabWidth;
}

blockBasenames.forEach( ( basename ) => {
// eslint-disable-next-line jest/valid-title
it( basename, () => {
Expand All @@ -98,7 +106,7 @@ describe( 'full post content fixture', () => {
parserOutputExpectedString = parsedJSONFixtureContent;
} else if ( process.env.GENERATE_MISSING_FIXTURES ) {
parserOutputExpectedString =
JSON.stringify( parserOutputActual, null, 4 ) + '\n';
JSON.stringify( parserOutputActual, null, spacer ) + '\n';
writeBlockFixtureParsedJSON(
basename,
parserOutputExpectedString
Expand Down Expand Up @@ -152,7 +160,8 @@ describe( 'full post content fixture', () => {
blocksExpectedString = jsonFixtureContent;
} else if ( process.env.GENERATE_MISSING_FIXTURES ) {
blocksExpectedString =
JSON.stringify( blocksActualNormalized, null, 4 ) + '\n';
JSON.stringify( blocksActualNormalized, null, spacer ) +
'\n';
writeBlockFixtureJSON( basename, blocksExpectedString );
} else {
throw new Error(
Expand Down

0 comments on commit 2190665

Please sign in to comment.