Skip to content

Commit

Permalink
Update reducer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Apr 29, 2024
1 parent ba8c647 commit d628645
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions packages/blocks/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ describe( 'blockStyles', () => {
expect( blockStyles( undefined, {} ) ).toEqual( {} );
} );

it( 'should add a new block styles', () => {
it( 'should add new block styles for a single block type', () => {
const original = deepFreeze( {} );

let state = blockStyles( original, {
type: 'ADD_BLOCK_STYLES',
blockName,
blockNames: [ blockName ],
styles: [ { name: 'fancy' } ],
} );

Expand All @@ -123,7 +123,7 @@ describe( 'blockStyles', () => {

state = blockStyles( state, {
type: 'ADD_BLOCK_STYLES',
blockName,
blockNames: [ blockName ],
styles: [ { name: 'lightbox' } ],
} );

Expand All @@ -132,6 +132,32 @@ describe( 'blockStyles', () => {
} );
} );

it( 'should add block styles for array of block types', () => {
const original = deepFreeze( {} );

let state = blockStyles( original, {
type: 'ADD_BLOCK_STYLES',
blockNames: [ 'core/group', 'core/columns' ],
styles: [ { name: 'dark' } ],
} );

expect( state ).toEqual( {
'core/group': [ { name: 'dark' } ],
'core/columns': [ { name: 'dark' } ],
} );

state = blockStyles( state, {
type: 'ADD_BLOCK_STYLES',
blockNames: [ 'core/group' ],
styles: [ { name: 'light' } ],
} );

expect( state ).toEqual( {
'core/group': [ { name: 'dark' }, { name: 'light' } ],
'core/columns': [ { name: 'dark' } ],
} );
} );

it( 'should prepend block styles when adding a block', () => {
const original = deepFreeze( {
[ blockName ]: [ { name: 'fancy' } ],
Expand Down

0 comments on commit d628645

Please sign in to comment.