Skip to content

Commit

Permalink
Add selector tests for getDownloadableBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ryelle committed May 22, 2020
1 parent 884a473 commit 01cb9b4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/block-directory/src/store/test/selectors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/**
* Internal dependencies
*/
import { downloadableBlock } from './fixtures';
import {
getDownloadableBlocks,
getErrorNotices,
getErrorNoticeForBlock,
getInstalledBlockTypes,
Expand Down Expand Up @@ -59,4 +61,25 @@ describe( 'selectors', () => {
expect( errorNotice ).toEqual( false );
} );
} );

describe( 'getDownloadableBlocks', () => {
const state = {
downloadableBlocks: {
isRequestingDownloadableBlocks: false,
results: {
boxer: [ downloadableBlock ],
},
},
};

it( 'should get the list of available blocks for a query', () => {
const blocks = getDownloadableBlocks( state, 'boxer' );
expect( blocks ).toHaveLength( 1 );
} );

it( 'should get an empty array if no matching query is found', () => {
const blocks = getDownloadableBlocks( state, 'not-found' );
expect( blocks ).toEqual( [] );
} );
} );
} );

0 comments on commit 01cb9b4

Please sign in to comment.