Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Update all tests which depend on editor #6738

Merged
merged 1 commit into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 2 additions & 37 deletions blocks/api/test/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe( 'block factory', () => {
};

beforeAll( () => {
// Load all hooks that modify blocks
require( 'editor/hooks' );
// Load blocks store
require( 'blocks/store' );
} );

afterEach( () => {
Expand Down Expand Up @@ -78,41 +78,6 @@ describe( 'block factory', () => {
expect( block.innerBlocks[ 0 ].name ).toBe( 'core/test-block' );
expect( typeof block.uid ).toBe( 'string' );
} );

it( 'should keep the className if the block supports it', () => {
registerBlockType( 'core/test-block', {
attributes: {},
save: noop,
category: 'common',
title: 'test block',
} );
const block = createBlock( 'core/test-block', {
className: 'chicken',
} );

expect( block.attributes ).toEqual( {
className: 'chicken',
} );
expect( block.isValid ).toBe( true );
} );

it( 'should not keep the className if the block supports it', () => {
registerBlockType( 'core/test-block', {
attributes: {},
save: noop,
category: 'common',
title: 'test block',
supports: {
customClassName: false,
},
} );
const block = createBlock( 'core/test-block', {
className: 'chicken',
} );

expect( block.attributes ).toEqual( {} );
expect( block.isValid ).toBe( true );
} );
} );

describe( 'cloneBlock()', () => {
Expand Down
12 changes: 6 additions & 6 deletions blocks/api/test/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe( 'block parser', () => {
};

beforeAll( () => {
// Load all hooks that modify blocks
require( 'editor/hooks' );
// Initialize the block store.
require( '../../store' );
} );

afterEach( () => {
Expand Down Expand Up @@ -235,7 +235,7 @@ describe( 'block parser', () => {
},
],
},
'<span class="wp-block-test-block">Bananas</span>',
'<span>Bananas</span>',
{},
);
expect( attributesAndInnerBlocks.attributes ).toEqual( { fruit: 'Bananas' } );
Expand All @@ -260,7 +260,7 @@ describe( 'block parser', () => {
},
],
},
'<span class="wp-block-test-block">Bananas</span>',
'<span>Bananas</span>',
{},
[ {
name: 'core/test-block',
Expand Down Expand Up @@ -301,7 +301,7 @@ describe( 'block parser', () => {
},
],
},
'<span class="wp-block-test-block">Bananas</span>',
'<span>Bananas</span>',
{},
);

Expand Down Expand Up @@ -396,7 +396,7 @@ describe( 'block parser', () => {

const block = createBlockWithFallback( {
blockName: 'core/test-block',
innerHTML: '<span class="wp-block-test-block">Bananas</span>',
innerHTML: '<span>Bananas</span>',
attrs: { fruit: 'Bananas' },
} );
expect( block.name ).toEqual( 'core/test-block' );
Expand Down
75 changes: 1 addition & 74 deletions blocks/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ describe( 'blocks', () => {
const defaultBlockSettings = { save: noop, category: 'common', title: 'block title' };

beforeAll( () => {
// Load all hooks that modify blocks
require( 'editor/hooks' );

// Initialize the block store
// Initialize the block store.
require( '../../store' );
} );

Expand Down Expand Up @@ -91,14 +88,6 @@ describe( 'blocks', () => {
save: noop,
category: 'common',
title: 'block title',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
} );

Expand Down Expand Up @@ -183,12 +172,6 @@ describe( 'blocks', () => {
ok: {
type: 'boolean',
},
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
} );
Expand All @@ -204,14 +187,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
} );

Expand Down Expand Up @@ -250,14 +225,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
},
] );
const oldBlock = unregisterBlockType( 'core/test-block' );
Expand All @@ -268,14 +235,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
expect( getBlockTypes() ).toEqual( [] );
} );
Expand Down Expand Up @@ -318,14 +277,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
} );

Expand All @@ -339,14 +290,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
} );
} );
} );
Expand All @@ -367,14 +310,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
},
{
name: 'core/test-block-with-settings',
Expand All @@ -383,14 +318,6 @@ describe( 'blocks', () => {
category: 'common',
title: 'block title',
icon: 'block-default',
attributes: {
className: {
type: 'string',
},
layout: {
type: 'string',
},
},
},
] );
} );
Expand Down
Loading