From 2190665a89f203a3e55409c03355b2f2a01a8920 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 14 Apr 2021 07:37:43 +0200 Subject: [PATCH] Fixture regeneration: Infer tabs use from prettier config (#30813) * Fixture Regeneration: Use tabs * Fixture regeneration: Infer tabs use from prettier config --- test/integration/full-content/full-content.test.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/integration/full-content/full-content.test.js b/test/integration/full-content/full-content.test.js index 480425d77da26c..12957f251fe538 100644 --- a/test/integration/full-content/full-content.test.js +++ b/test/integration/full-content/full-content.test.js @@ -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, @@ -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, () => { @@ -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 @@ -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(