Skip to content

Commit

Permalink
blocks/store/reducer.js // add test case for unique catgories by slug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrico committed Aug 1, 2024
1 parent 913ff90 commit a72049a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/blocks/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,22 @@ describe( 'categories', () => {
expect( state ).toEqual( [ { slug: 'wings', title: 'Wings' } ] );
} );

it( 'should ensure, that categories are unique by slug', () => {
const original = deepFreeze( [
{ slug: 'chicken', title: 'Chicken' },
] );

const state = categories( original, {
type: 'SET_CATEGORIES',
categories: [ { slug: 'chicken', title: 'Another chicken' } ],
} );

expect( state ).toEqual( [
{ slug: 'chicken', title: 'Another chicken' },
] );
expect( state.length ).toBe( 1 );
} );

it( 'should add the category icon', () => {
const original = deepFreeze( [
{
Expand Down

0 comments on commit a72049a

Please sign in to comment.