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

Add tests for Editable.getSettings() #3892

Merged
merged 1 commit into from
Dec 23, 2017
Merged

Conversation

BE-Webdesign
Copy link
Contributor

Add tests for Editable.getSettings()

@BE-Webdesign BE-Webdesign added the [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. label Dec 9, 2017
} );

test( 'should be overriden', () => {
const mock = jest.fn().mockImplementation( ( setting ) => 'mocked' ); // eslint-disable-line no-unused-vars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is perfectly valid to omit setting in function definition instead of disabling Eslint check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also pass callback to jest.fn instead of using mockImplementation. See https://facebook.github.io/jest/docs/en/mock-functions.html#mock-implementations.

const mock = jest.fn( () => 'mocked'  );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, makes sense.

describe( 'Component', () => {
describe( '.getSettings', () => {
const value = [ 'Hi!' ];
const wrapper = shallow( <Editable value={ value } /> );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper is used only in one tests. It would be better to put it there, because the other tests uses a different wrapper.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some minor comments, which aren't blockers. This looks good. Again, this tests a private method, which isn't ideal. Let's move on with this anyway :)

@BE-Webdesign BE-Webdesign force-pushed the add/test/blocks/editable-2 branch 2 times, most recently from db8142e to e8e7eb1 Compare December 23, 2017 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants