Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Oct 11, 2024
1 parent c2fc971 commit 4f348b8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { RawHTML } from '@wordpress/element';
import { symbol } from '@wordpress/icons';
import { select, dispatch } from '@wordpress/data';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
Expand Down Expand Up @@ -4470,7 +4471,6 @@ describe( 'getBlockEditingMode', () => {

const navigationModeStateWithRootSection = {
...baseState,
editorMode: 'navigation',
settings: {
[ sectionRootClientIdKey ]: 'ef45d5fd-5234-4fd5-ac4f-c3736c7f9337', // The group is the "main" container
},
Expand All @@ -4480,12 +4480,18 @@ describe( 'getBlockEditingMode', () => {

const fauxPrivateAPIs = {};

lock( fauxPrivateAPIs, { hasContentRoleAttribute } );
lock( fauxPrivateAPIs, {
hasContentRoleAttribute,
} );

getBlockEditingMode.registry = {
select: jest.fn( () => fauxPrivateAPIs ),
};

afterEach( () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', undefined );
} );

it( 'should return default by default', () => {
expect(
getBlockEditingMode(
Expand Down Expand Up @@ -4610,6 +4616,7 @@ describe( 'getBlockEditingMode', () => {
} );

it( 'in navigation mode, the root section container is default', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
Expand All @@ -4619,6 +4626,7 @@ describe( 'getBlockEditingMode', () => {
} );

it( 'in navigation mode, anything outside the section container is disabled', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
Expand All @@ -4628,6 +4636,7 @@ describe( 'getBlockEditingMode', () => {
} );

it( 'in navigation mode, sections are contentOnly', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
Expand All @@ -4643,6 +4652,7 @@ describe( 'getBlockEditingMode', () => {
} );

it( 'in navigation mode, blocks with content attributes within sections are contentOnly', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
hasContentRoleAttribute.mockReturnValueOnce( true );
expect(
getBlockEditingMode(
Expand All @@ -4661,6 +4671,7 @@ describe( 'getBlockEditingMode', () => {
} );

it( 'in navigation mode, blocks without content attributes within sections are disabled', () => {
dispatch( preferencesStore ).set( 'core', 'editorTool', 'navigation' );
expect(
getBlockEditingMode(
navigationModeStateWithRootSection,
Expand Down

0 comments on commit 4f348b8

Please sign in to comment.