Skip to content

Commit

Permalink
remove bad test
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienMattiussi authored and akshah123 committed Feb 14, 2020
1 parent c947f33 commit 8c66216
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions packages/ra-ui-materialui/src/button/SaveButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import React from 'react';
import expect from 'expect';
import { TestContext } from 'ra-core';

import Create from '../detail/Create';
import SimpleForm from '../form/SimpleForm';
import Toolbar from '../form/Toolbar';
import TextInput from '../input/TextInput';
import SaveButton from './SaveButton';

describe('<SaveButton />', () => {
Expand Down Expand Up @@ -45,50 +41,8 @@ describe('<SaveButton />', () => {
/>
</TestContext>
);
fireEvent.click(getByLabelText('ra.action.save'));
expect(onSubmit).toHaveBeenCalled();
});

it('should trigger submit action when Enter key if no saving is in progress', () => {
const onSubmit = jest.fn();

const defaultCreateProps = {
basePath: '/foo',
id: '123',
resource: 'foo',
location: {},
match: {},
};

const SaveToolbar = props => (
<Toolbar {...props}>
<SaveButton
label="enterButton"
handleSubmitWithRedirect={onSubmit}
submitOnEnter={true}
saving={false}
/>
</Toolbar>
);

const { getByLabelText } = render(
<TestContext>
<Create {...defaultCreateProps}>
<SimpleForm toolbar={<SaveToolbar />}>
<TextInput label="Title" source="title" />
</SimpleForm>
</Create>
</TestContext>
);

const input = getByLabelText('Title');
fireEvent.focus(input);
fireEvent.change(input, { target: { value: 'test' } });

const button = getByLabelText('enterButton');
//console.log(button);
//fireEvent.click(getByLabelText('ra.action.save'));
fireEvent.keyPress(input, { key: 'Enter', keyCode: 13 });
fireEvent.click(getByLabelText('ra.action.save'));
expect(onSubmit).toHaveBeenCalled();
});

Expand Down

0 comments on commit 8c66216

Please sign in to comment.