Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Dec 13, 2023
1 parent b9725db commit 79e78da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 51 deletions.
26 changes: 0 additions & 26 deletions packages/edit-post/src/store/test/reducer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
/**
* External dependencies
*/
import deepFreeze from 'deep-freeze';

/**
* Internal dependencies
*/
import {
isSavingMetaBoxes,
metaBoxLocations,
removedPanels,
blockInserterPanel,
listViewPanel,
} from '../reducer';
Expand Down Expand Up @@ -95,26 +89,6 @@ describe( 'state', () => {
} );
} );

describe( 'removedPanels', () => {
it( 'should remove panel', () => {
const original = deepFreeze( [] );
const state = removedPanels( original, {
type: 'REMOVE_PANEL',
panelName: 'post-status',
} );
expect( state ).toEqual( [ 'post-status' ] );
} );

it( 'should not remove already removed panel', () => {
const original = deepFreeze( [ 'post-status' ] );
const state = removedPanels( original, {
type: 'REMOVE_PANEL',
panelName: 'post-status',
} );
expect( state ).toBe( original );
} );
} );

describe( 'blockInserterPanel()', () => {
it( 'should apply default state', () => {
expect( blockInserterPanel( undefined, {} ) ).toEqual( false );
Expand Down
25 changes: 0 additions & 25 deletions packages/editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,6 @@ describe( 'Editor actions', () => {
.isEditorPanelEnabled( 'control-panel' )
).toBe( false );

// Also check that the `getPreference` selector includes panels.
expect(
registry.select( editorStore ).getPreference( 'panels' )
).toEqual( {
'control-panel': {
enabled: false,
},
} );

// Switch it on again.
registry
.dispatch( editorStore )
Expand All @@ -467,10 +458,6 @@ describe( 'Editor actions', () => {
.select( editorStore )
.isEditorPanelEnabled( 'control-panel' )
).toBe( true );

expect(
registry.select( editorStore ).getPreference( 'panels' )
).toEqual( {} );
} );
} );

Expand All @@ -489,14 +476,6 @@ describe( 'Editor actions', () => {
.isEditorPanelOpened( 'control-panel' )
).toBe( true );

expect(
registry.select( editorStore ).getPreference( 'panels' )
).toEqual( {
'control-panel': {
opened: true,
},
} );

// Close it.
registry
.dispatch( editorStore )
Expand All @@ -507,10 +486,6 @@ describe( 'Editor actions', () => {
.select( editorStore )
.isEditorPanelOpened( 'control-panel' )
).toBe( false );

expect(
registry.select( editorStore ).getPreference( 'panels' )
).toEqual( {} );
} );
} );
} );
21 changes: 21 additions & 0 deletions packages/editor/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
saving,
postSavingLock,
postAutosavingLock,
removedPanels,
} from '../reducer';

describe( 'state', () => {
Expand Down Expand Up @@ -264,4 +265,24 @@ describe( 'state', () => {
expect( state ).toEqual( {} );
} );
} );

describe( 'removedPanels', () => {
it( 'should remove panel', () => {
const original = deepFreeze( [] );
const state = removedPanels( original, {
type: 'REMOVE_PANEL',
panelName: 'post-status',
} );
expect( state ).toEqual( [ 'post-status' ] );
} );

it( 'should not remove already removed panel', () => {
const original = deepFreeze( [ 'post-status' ] );
const state = removedPanels( original, {
type: 'REMOVE_PANEL',
panelName: 'post-status',
} );
expect( state ).toBe( original );
} );
} );
} );

0 comments on commit 79e78da

Please sign in to comment.