Skip to content

Commit

Permalink
Deep freeze initial state for downloadable blocks test.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 10, 2020
1 parent 3d1d6c0 commit afc0377
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions packages/block-directory/src/store/test/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { installedItem, downloadableBlock } from './fixtures';
describe( 'state', () => {
describe( 'downloadableBlocks()', () => {
it( 'should update state to reflect active search', () => {
const initialState = {};
const initialState = deepFreeze( {} );
const filterValue = 'Awesome Block';

const state = downloadableBlocks( initialState, {
Expand All @@ -30,11 +30,11 @@ describe( 'state', () => {

it( 'should update state to reflect search results have returned', () => {
const query = downloadableBlock.title;
const initialState = {
const initialState = deepFreeze( {
[ query ]: {
isRequesting: true,
},
};
} );

const state = downloadableBlocks( initialState, {
type: 'RECEIVE_DOWNLOADABLE_BLOCKS',
Expand All @@ -47,14 +47,12 @@ describe( 'state', () => {

it( "should set user's search term and save results", () => {
const query = downloadableBlock.title;
const state = downloadableBlocks(
{},
{
type: 'RECEIVE_DOWNLOADABLE_BLOCKS',
filterValue: query,
downloadableBlocks: [ downloadableBlock ],
}
);
const initialState = deepFreeze( {} );
const state = downloadableBlocks( initialState, {
type: 'RECEIVE_DOWNLOADABLE_BLOCKS',
filterValue: query,
downloadableBlocks: [ downloadableBlock ],
} );
expect( state ).toHaveProperty( query );
expect( state[ query ].results ).toHaveLength( 1 );
} );
Expand Down

0 comments on commit afc0377

Please sign in to comment.