diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js index 43f5cacc8d8eb2..5c0fc239cd009c 100644 --- a/packages/edit-site/src/components/style-book/index.js +++ b/packages/edit-site/src/components/style-book/index.js @@ -149,6 +149,7 @@ function StyleBook( { ) : ( { - beforeAll( () => { - // Register all core blocks - registerCoreBlocks(); - } ); - - afterAll( () => { - // Clean up registered blocks - getBlockTypes().forEach( ( block ) => { - unregisterBlockType( block.name ); - } ); - } ); - describe( 'getCategoryExamples', () => { - it( 'returns category key value pairs', () => { + it( 'returns theme subcategories examples', () => { const themeCategory = STYLE_BOOK_CATEGORIES.find( ( category ) => category.name === 'theme' ); const themeCategoryExamples = getCategoryExamples( themeCategory, - getExamples() + exampleThemeBlocks ); + expect( themeCategoryExamples.name ).toEqual( 'theme' ); - expect( themeCategoryExamples.subcategories ).toHaveLength( - themeCategory.subcategories.length + + const siteIdentity = themeCategoryExamples.subcategories.find( + ( subcategory ) => subcategory.name === 'site-identity' + ); + expect( siteIdentity ).toEqual( { + title: 'Site Identity', + name: 'site-identity', + examples: [ + { + name: 'core/site-logo', + title: 'Site Logo', + category: 'theme', + }, + { + name: 'core/site-title', + title: 'Site Title', + category: 'theme', + }, + { + name: 'core/site-tagline', + title: 'Site Tagline', + category: 'theme', + }, + ], + } ); + + const design = themeCategoryExamples.subcategories.find( + ( subcategory ) => subcategory.name === 'design' ); + expect( design ).toEqual( { + title: 'Design', + name: 'design', + examples: [ + { + name: 'core/group', + title: 'Group', + category: 'design', + }, + ], + } ); + + const posts = themeCategoryExamples.subcategories.find( + ( subcategory ) => subcategory.name === 'posts' + ); + + expect( posts ).toEqual( { + title: 'Posts', + name: 'posts', + examples: [ + { + name: 'core/post-terms', + title: 'Post Terms', + category: 'theme', + }, + ], + } ); } ); } ); } ); diff --git a/packages/edit-site/src/components/style-book/utils.js b/packages/edit-site/src/components/style-book/utils.js index 1484f817dd89e2..d3c3876669de72 100644 --- a/packages/edit-site/src/components/style-book/utils.js +++ b/packages/edit-site/src/components/style-book/utils.js @@ -100,19 +100,6 @@ export function getCategoryExamples( categoryDefinition, examples ) { return { title: categoryDefinition.title, name: categoryDefinition.name, - examples: examples.filter( ( example ) => { - return ( - ! blocksToExclude.includes( example.name ) && - ( example.category === categoryDefinition.name || - blocksToInclude.includes( example.name ) ) - ); - } ), + examples: categoryExamples, }; } - -/* - - - - - */