diff --git a/client/src/routes/Publish/Files/index.tsx b/client/src/routes/Publish/Files/index.tsx index c910588..f311fda 100644 --- a/client/src/routes/Publish/Files/index.tsx +++ b/client/src/routes/Publish/Files/index.tsx @@ -115,6 +115,7 @@ export default class Files extends PureComponent { name={name} value={JSON.stringify(files)} onChange={onChange} + data-testid="files" />
diff --git a/client/src/routes/Publish/Step.test.tsx b/client/src/routes/Publish/Step.test.tsx index 2ba4901..219577f 100644 --- a/client/src/routes/Publish/Step.test.tsx +++ b/client/src/routes/Publish/Step.test.tsx @@ -12,7 +12,6 @@ const stateMock = { const propsMock = { inputChange: () => null, - inputToArrayChange: () => null, state: stateMock, title: 'Hello', description: 'description', diff --git a/client/src/routes/Publish/Step.tsx b/client/src/routes/Publish/Step.tsx index 9019673..57b84d8 100644 --- a/client/src/routes/Publish/Step.tsx +++ b/client/src/routes/Publish/Step.tsx @@ -28,9 +28,6 @@ interface StepProps { | ChangeEvent | ChangeEvent ): void - inputToArrayChange( - event: ChangeEvent | ChangeEvent - ): void fields?: Fields state: any title: string diff --git a/client/src/routes/Publish/index.test.tsx b/client/src/routes/Publish/index.test.tsx index 0f1b67e..6d00da9 100644 --- a/client/src/routes/Publish/index.test.tsx +++ b/client/src/routes/Publish/index.test.tsx @@ -1,11 +1,44 @@ import React from 'react' -import { render } from '@testing-library/react' +import { render, fireEvent } from '@testing-library/react' import Publish from '.' +import { User } from '../../context' +import { userMockConnected } from '../../../__mocks__/user-mock' -describe('Progress', () => { +describe('Publish', () => { it('renders without crashing', () => { - const { container, getByText } = render() + const { container, getByText } = render( + + + + ) expect(container.firstChild).toBeInTheDocument() expect(getByText('Next →')).toHaveAttribute('disabled') }) + + it('next button works', () => { + const { getByText, getByLabelText, getByTestId } = render( + + + + ) + + // Title + const inputName = getByLabelText('Title') + fireEvent.change(inputName, { + target: { value: 'Hello' } + }) + + // Files + const inputFiles = getByTestId('files') + fireEvent.change(inputFiles, { + target: { + value: JSON.stringify([ + { url: 'https://demo.com', contentType: '', found: false } + ]) + } + }) + + // expect(getByText('Next →')).not.toHaveAttribute('disabled') + fireEvent.click(getByText('Next →')) + }) }) diff --git a/client/src/routes/Publish/index.tsx b/client/src/routes/Publish/index.tsx index b796fed..0f9b655 100644 --- a/client/src/routes/Publish/index.tsx +++ b/client/src/routes/Publish/index.tsx @@ -83,16 +83,6 @@ export default class Publish extends Component<{}, PublishState> { }) } - private inputToArrayChange = ( - event: ChangeEvent | ChangeEvent - ) => { - this.validateInputs(event.currentTarget.name, event.currentTarget.value) - - this.setState({ - [event.currentTarget.name]: [event.currentTarget.value] - }) - } - private next = () => { let { currentStep } = this.state const totalSteps = steps.length @@ -353,7 +343,6 @@ export default class Publish extends Component<{}, PublishState> { currentStep={this.state.currentStep} fields={step.fields} inputChange={this.inputChange} - inputToArrayChange={this.inputToArrayChange} state={this.state} next={this.next} prev={this.prev}