Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update unit tests for template parts
  • Loading branch information
talldan committed Dec 24, 2024
commit e8c33f12bbfe1d2dda2a44e2a026def7712b9337
75 changes: 55 additions & 20 deletions packages/block-editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3975,38 +3975,58 @@ describe( 'state', () => {
{
type: 'UPDATE_SETTINGS',
settings: {
[ sectionRootClientIdKey ]: '',
[ sectionRootClientIdKey ]: 'section-root',
},
},
{
type: 'RESET_BLOCKS',
blocks: [
{
name: 'core/template-part',
clientId: 'header',
attributes: {},
innerBlocks: [],
},
{
name: 'core/group',
clientId: 'group-1',
clientId: 'section-root',
attributes: {},
innerBlocks: [
{
name: 'core/paragraph',
clientId: 'paragraph-1',
attributes: {},
innerBlocks: [],
},
{
name: 'core/group',
clientId: 'group-2',
clientId: 'group-1',
attributes: {},
innerBlocks: [
{
name: 'core/paragraph',
clientId: 'paragraph-2',
clientId: 'paragraph-1',
attributes: {},
innerBlocks: [],
},
{
name: 'core/group',
clientId: 'group-2',
attributes: {},
innerBlocks: [
{
name: 'core/paragraph',
clientId:
'paragraph-2',
attributes: {},
innerBlocks: [],
},
],
},
],
},
],
},
{
name: 'core/template-part',
clientId: 'footer',
attributes: {},
innerBlocks: [],
},
],
},
],
Expand All @@ -4022,7 +4042,10 @@ describe( 'state', () => {
expect( initialState.derivedNavModeBlockEditingModes ).toEqual(
new Map(
Object.entries( {
'': 'contentOnly', // Section root.
'': 'disabled',
header: 'contentOnly', // Template part.
footer: 'contentOnly', // Template part.
'section-root': 'contentOnly', // Section root.
'group-1': 'contentOnly', // Section block.
'paragraph-1': 'contentOnly', // Content block in section.
'group-2': 'disabled', // Non-content block in section.
Expand All @@ -4047,7 +4070,10 @@ describe( 'state', () => {
expect( derivedNavModeBlockEditingModes ).toEqual(
new Map(
Object.entries( {
'': 'contentOnly',
'': 'disabled',
header: 'contentOnly',
footer: 'contentOnly',
'section-root': 'contentOnly',
'group-1': 'contentOnly',
'paragraph-1': 'contentOnly',
} )
Expand All @@ -4060,7 +4086,7 @@ describe( 'state', () => {
[
{
type: 'INSERT_BLOCKS',
rootClientId: '',
rootClientId: 'section-root',
blocks: [
{
name: 'core/group',
Expand Down Expand Up @@ -4091,7 +4117,10 @@ describe( 'state', () => {
expect( derivedNavModeBlockEditingModes ).toEqual(
new Map(
Object.entries( {
'': 'contentOnly', // Section root.
'': 'disabled', // Section root.
header: 'contentOnly', // Template part.
footer: 'contentOnly', // Template part.
'section-root': 'contentOnly', // Section root.
'group-1': 'contentOnly', // Section block.
'paragraph-1': 'contentOnly', // Content block in section.
'group-2': 'disabled', // Non-content block in section.
Expand All @@ -4111,7 +4140,7 @@ describe( 'state', () => {
type: 'MOVE_BLOCKS_TO_POSITION',
clientIds: [ 'group-2' ],
fromRootClientId: 'group-1',
toRootClientId: '',
toRootClientId: 'section-root',
},
],
testReducer,
Expand All @@ -4120,7 +4149,10 @@ describe( 'state', () => {
expect( derivedNavModeBlockEditingModes ).toEqual(
new Map(
Object.entries( {
'': 'contentOnly', // Section root.
'': 'disabled', // Section root.
header: 'contentOnly', // Template part.
footer: 'contentOnly', // Template part.
'section-root': 'contentOnly', // Section root.
'group-1': 'contentOnly', // Section block.
'paragraph-1': 'contentOnly', // Content block in section.
'group-2': 'contentOnly', // New section block.
Expand Down Expand Up @@ -4148,10 +4180,13 @@ describe( 'state', () => {
new Map(
Object.entries( {
'': 'disabled',
'group-1': 'contentOnly',
'paragraph-1': 'contentOnly',
'group-2': 'contentOnly',
'paragraph-2': 'contentOnly',
header: 'contentOnly',
footer: 'contentOnly',
'section-root': 'disabled',
'group-1': 'contentOnly', // New section root.
'paragraph-1': 'contentOnly', // Section and content block
'group-2': 'contentOnly', // Section.
'paragraph-2': 'contentOnly', // Content block.
} )
)
);
Expand Down