Skip to content

Commit

Permalink
Add back in tests removed in rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 19, 2020
1 parent e345ade commit 53fc2ab
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions packages/block-directory/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,76 @@ describe( 'selectors', () => {
} );
} );

describe( 'getNewBlockTypes', () => {
it( 'should retrieve the block types that are installed and in the post content', () => {
getNewBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => blockList } ) ),
};
const state = {
blockManagement: {
installedBlockTypes: [
blockTypeInstalled,
blockTypeUnused,
],
},
};
const blockTypes = getNewBlockTypes( state );
expect( blockTypes ).toHaveLength( 1 );
expect( blockTypes[ 0 ] ).toEqual( blockTypeInstalled );
} );

it( 'should return an empty array if no blocks are used', () => {
getNewBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => [] } ) ),
};
const state = {
blockManagement: {
installedBlockTypes: [
blockTypeInstalled,
blockTypeUnused,
],
},
};
const blockTypes = getNewBlockTypes( state );
expect( blockTypes ).toHaveLength( 0 );
} );
} );

describe( 'getUnusedBlockTypes', () => {
it( 'should retrieve the block types that are installed but not used', () => {
getUnusedBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => blockList } ) ),
};
const state = {
blockManagement: {
installedBlockTypes: [
blockTypeInstalled,
blockTypeUnused,
],
},
};
const blockTypes = getUnusedBlockTypes( state );
expect( blockTypes ).toHaveLength( 1 );
expect( blockTypes[ 0 ] ).toEqual( blockTypeUnused );
} );

it( 'should return all block types if no blocks are used', () => {
getUnusedBlockTypes.registry = {
select: jest.fn( () => ( { getBlocks: () => [] } ) ),
};
const state = {
blockManagement: {
installedBlockTypes: [
blockTypeInstalled,
blockTypeUnused,
],
},
};
const blockTypes = getUnusedBlockTypes( state );
expect( blockTypes ).toHaveLength( 2 );
} );
} );

describe( 'getErrorNoticeForBlock', () => {
const state = {
errorNotices: {
Expand Down

0 comments on commit 53fc2ab

Please sign in to comment.