Skip to content

Commit

Permalink
Add basic tests for ChannelForm.
Browse files Browse the repository at this point in the history
  • Loading branch information
willgraf committed Mar 12, 2021
1 parent ad202df commit 927b814
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions src/Predict/ChannelForm.test.js
@@ -0,0 +1,25 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import ChannelForm from './ChannelForm';

describe('<ChannelForm/> component tests', () => {

it('<ChannelForm/> renders with targets as labels.', () => {
// const { targetChannels, channels, onChange } = props;
const target1 = 'channelLabel';
const target2 = 'channelLabel2';
const { getByText } = render(
<ChannelForm
targetChannels={{ [target1]: 'R', [target2]: 'G' }}
channels={['B', 'R', 'G', 'B']}
/>
);
const element1 = getByText(`${target1} channel`);
expect(element1).toBeInTheDocument();

const element2 = getByText(`${target2} channel`);
expect(element2).toBeInTheDocument();
});

});
3 changes: 2 additions & 1 deletion src/Predict/Predict.js
Expand Up @@ -161,7 +161,8 @@ export default function Predict() {
imageUrl: imageUrl,
jobType: selectedJobType,
dataRescale: isAutoRescaleEnabled ? (displayRescaleForm ? '' : '1') : scale,
channels: (jobData[selectedJobType].requiredChannels).map(c => channelValues[targetChannels[c]]).join(','),
channels: (jobData[selectedJobType].requiredChannels).map(
c => channelValues[targetChannels[c]]).join(','),
}
}).then((response) => {
checkJobStatus(response.data.hash, 3000);
Expand Down

0 comments on commit 927b814

Please sign in to comment.