Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to react testing lib instead of enzyme (#679)
* Migrate to react testing lib instead of enzyme * Reformat the tests with prettier
- Loading branch information
Showing
33 changed files
with
1,393 additions
and
1,323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import React from 'react'; | ||
import { withFormsy } from '../src'; | ||
import { PassDownProps } from '../src/withFormsy'; | ||
|
||
class TestComponent extends React.Component { | ||
type TestComponentProps = { testId?: string; name?: string } & PassDownProps<string>; | ||
|
||
class TestComponent extends React.Component<TestComponentProps> { | ||
render() { | ||
return <input />; | ||
const { testId, name } = this.props; | ||
return <input data-testid={testId} name={name} />; | ||
} | ||
} | ||
|
||
export default withFormsy(TestComponent as any); | ||
export default withFormsy<TestComponentProps, any>(TestComponent); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import Formsy from '../src'; | ||
import { InputFactory } from './TestInput'; | ||
|
||
const TestInput = InputFactory({ | ||
render() { | ||
const { value, isValid, testId } = this.props; | ||
return <input value={value || ''} readOnly data-is-valid={isValid} data-testid={testId} />; | ||
}, | ||
}); | ||
|
||
function ValidationForm(props: { validations: string; value?: any }) { | ||
const { validations, value } = props; | ||
|
||
return ( | ||
<Formsy> | ||
<TestInput name="foo" validations={validations} value={value} testId="test-input" /> | ||
</Formsy> | ||
); | ||
} | ||
|
||
export async function getValidState(testForm: React.ComponentElement<any, any>) { | ||
const form = render(testForm); | ||
const inputComponent = await form.findByTestId('test-input'); | ||
|
||
return inputComponent.dataset.isValid === 'true'; | ||
} | ||
|
||
export default ValidationForm; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.