Skip to content

Commit

Permalink
Blocks: Add test case to verify behavior omitting category
Browse files Browse the repository at this point in the history
Search implementation leverages block category, which may be absent. It did not actually require changes to the implementation to support, but the test case can help assure this continues to be supported into the future.
  • Loading branch information
aduth committed May 12, 2020
1 parent 9b643f0 commit bf5f678
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions packages/blocks/src/store/test/selectors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* External dependencies
*/
import { omit } from 'lodash';

import deepFreeze from 'deep-freeze';

/**
Expand Down Expand Up @@ -243,6 +245,7 @@ describe( 'selectors', () => {
describe.each( [
[ 'name', name ],
[ 'block type', blockType ],
[ 'block type without category', omit( blockType, 'category' ) ],
] )( 'by %s', ( label, nameOrType ) => {
it( 'should return false if not match', () => {
const result = isMatchingSearchTerm(
Expand Down Expand Up @@ -304,15 +307,17 @@ describe( 'selectors', () => {
expect( result ).toBe( true );
} );

it( 'should return true if match using the categories', () => {
const result = isMatchingSearchTerm(
state,
nameOrType,
'COMMON'
);

expect( result ).toBe( true );
} );
if ( nameOrType.category ) {
it( 'should return true if match using the categories', () => {
const result = isMatchingSearchTerm(
state,
nameOrType,
'COMMON'
);

expect( result ).toBe( true );
} );
}
} );
} );

Expand Down

0 comments on commit bf5f678

Please sign in to comment.