Skip to content

Commit

Permalink
Merge pull request #3892 from WordPress/add/test/blocks/editable-2
Browse files Browse the repository at this point in the history
Add tests for Editable.getSettings()

This is a private method and the testing method may need to be reevaluated in the future.
  • Loading branch information
BE-Webdesign authored Dec 23, 2017
2 parents 204c6b8 + b393dbe commit 06317d7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions blocks/editable/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ describe( 'Editable', () => {
} );
} );
} );
describe( '.getSettings', () => {
const value = [ 'Hi!' ];
const settings = {
setting: 'hi',
};

test( 'should return expected settings', () => {
const wrapper = shallow( <Editable value={ value } /> );
expect( wrapper.instance().getSettings( settings ) ).toEqual( {
setting: 'hi',
forced_root_block: false,
} );
} );

test( 'should be overriden', () => {
const mock = jest.fn().mockImplementation( () => 'mocked' );

expect( shallow( <Editable value={ value } multiline={ true } getSettings={ mock } /> ).instance().getSettings( settings ) ).toEqual( 'mocked' );
} );
} );
} );
describe( '.propTypes', () => {
/* eslint-disable no-console */
Expand Down

0 comments on commit 06317d7

Please sign in to comment.