Skip to content

Commit caa2dce

Browse files
Minor adjustment
1 parent a50d6cd commit caa2dce

1 file changed

Lines changed: 50 additions & 8 deletions

File tree

src/__tests__/components/SegmentView.test.tsx

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ function requiredProps(): {
218218
simplifyPhrases: false,
219219
chapterLabelInVerse: false,
220220
showMorphology: false,
221-
showFreeTranslation: true,
221+
showFreeTranslation: false,
222222
},
223223
};
224224
}
@@ -340,15 +340,27 @@ describe('SegmentView', () => {
340340
});
341341

342342
it('renders a free-translation input below the plain text in baseline-text mode', () => {
343-
render(<SegmentView {...requiredProps()} displayMode="baseline-text" />, withAnalysisStore);
343+
render(
344+
<SegmentView
345+
{...requiredProps()}
346+
displayMode="baseline-text"
347+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
348+
/>,
349+
withAnalysisStore,
350+
);
344351

345352
expect(screen.getByTestId('segment-free-translation-input')).toBeInTheDocument();
346353
});
347354

348355
it('selects the segment once (via focus) when the baseline free-translation input is clicked', async () => {
349356
const handleSelect = jest.fn();
350357
render(
351-
<SegmentView {...requiredProps()} displayMode="baseline-text" onSelect={handleSelect} />,
358+
<SegmentView
359+
{...requiredProps()}
360+
displayMode="baseline-text"
361+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
362+
onSelect={handleSelect}
363+
/>,
352364
withAnalysisStore,
353365
);
354366

@@ -657,7 +669,13 @@ describe('SegmentView', () => {
657669
});
658670

659671
it('renders a free-translation input below the segment tokens', () => {
660-
render(<SegmentView {...requiredProps()} />, withAnalysisStore);
672+
render(
673+
<SegmentView
674+
{...requiredProps()}
675+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
676+
/>,
677+
withAnalysisStore,
678+
);
661679

662680
expect(screen.getByTestId('segment-free-translation-input')).toBeInTheDocument();
663681
});
@@ -688,7 +706,13 @@ describe('SegmentView', () => {
688706
});
689707

690708
it('commits the free translation on blur when the draft changed', async () => {
691-
render(<SegmentView {...requiredProps()} />, withAnalysisStore);
709+
render(
710+
<SegmentView
711+
{...requiredProps()}
712+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
713+
/>,
714+
withAnalysisStore,
715+
);
692716

693717
const input = screen.getByTestId('segment-free-translation-input');
694718
await userEvent.type(input, 'au commencement');
@@ -702,7 +726,13 @@ describe('SegmentView', () => {
702726
});
703727

704728
it('does not commit on blur when the draft is unchanged', async () => {
705-
render(<SegmentView {...requiredProps()} />, withAnalysisStore);
729+
render(
730+
<SegmentView
731+
{...requiredProps()}
732+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
733+
/>,
734+
withAnalysisStore,
735+
);
706736

707737
const input = screen.getByTestId('segment-free-translation-input');
708738
await userEvent.click(input);
@@ -713,7 +743,14 @@ describe('SegmentView', () => {
713743

714744
it('makes the segment active when the free-translation input is focused', async () => {
715745
const handleSelect = jest.fn();
716-
render(<SegmentView {...requiredProps()} onSelect={handleSelect} />, withAnalysisStore);
746+
render(
747+
<SegmentView
748+
{...requiredProps()}
749+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
750+
onSelect={handleSelect}
751+
/>,
752+
withAnalysisStore,
753+
);
717754

718755
await userEvent.click(screen.getByTestId('segment-free-translation-input'));
719756

@@ -723,7 +760,12 @@ describe('SegmentView', () => {
723760
it('does not select on free-translation focus when the segment has no word token', async () => {
724761
const handleSelect = jest.fn();
725762
render(
726-
<SegmentView {...requiredProps()} segment={PUNCT_SEGMENT} onSelect={handleSelect} />,
763+
<SegmentView
764+
{...requiredProps()}
765+
segment={PUNCT_SEGMENT}
766+
viewOptions={{ ...requiredProps().viewOptions, showFreeTranslation: true }}
767+
onSelect={handleSelect}
768+
/>,
727769
withAnalysisStore,
728770
);
729771

0 commit comments

Comments
 (0)