Skip to content

Commit ef2f6b7

Browse files
Add all-false ViewOptions test object (#121)
* Add free translation input to segment view * Minor adjustments * Minor adjustment * Reduce test * Refine localized-strings tests * Add all-false ViewOptions test object --------- Co-authored-by: Alex Rawlings <alex.rawlings@wycliffe.ca>
1 parent 094c16a commit ef2f6b7

4 files changed

Lines changed: 31 additions & 128 deletions

File tree

src/__tests__/components/ContinuousView.test.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type { PhraseDispatch } from '../../components/AnalysisStore';
1111
import ContinuousView from '../../components/ContinuousView';
1212
import { isWordToken } from '../../types/type-guards';
1313
import type { ViewOptions } from '../../types/view-options';
14-
import { withAnalysisStore } from './test-helpers';
14+
import { allFalseViewOptions, withAnalysisStore } from './test-helpers';
1515

1616
// ---------------------------------------------------------------------------
1717
// AnalysisStore mock — pass-through provider so AnalysisStore.tsx stays out of scope
@@ -431,13 +431,7 @@ function requiredProps(
431431
tokenSegmentMap,
432432
tokenDocOrder,
433433
wordTokenByRef,
434-
viewOptions: {
435-
hideInactiveLinkButtons: false,
436-
simplifyPhrases: false,
437-
chapterLabelInVerse: false,
438-
showMorphology: false,
439-
showFreeTranslation: false,
440-
},
434+
viewOptions: { ...allFalseViewOptions },
441435
};
442436
}
443437

@@ -902,13 +896,7 @@ describe('ContinuousView scroll behavior', () => {
902896
tokenSegmentMap={tokenSegmentMap}
903897
tokenDocOrder={tokenDocOrder}
904898
wordTokenByRef={wordTokenByRef}
905-
viewOptions={{
906-
hideInactiveLinkButtons: false,
907-
simplifyPhrases: false,
908-
chapterLabelInVerse: false,
909-
showMorphology: false,
910-
showFreeTranslation: false,
911-
}}
899+
viewOptions={{ ...allFalseViewOptions }}
912900
/>
913901
);
914902
}

src/__tests__/components/Interlinearizer.test.tsx

Lines changed: 16 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { InterlinearNavProvider } from '../../components/InterlinearNavContext';
1212
import type { SegmentDisplayMode } from '../../components/SegmentView';
1313
import { RECENTER_FADE_MS } from '../../components/recenter-fade';
1414
import { defaultScrRef, GEN_1_1_BOOK } from '../test-helpers';
15+
import { allFalseViewOptions } from './test-helpers';
1516

1617
jest.mock('lucide-react', () => ({
1718
__esModule: true,
@@ -519,13 +520,7 @@ describe('Interlinearizer', () => {
519520
analysisLanguage="und"
520521
phraseMode={{ kind: 'view' }}
521522
setPhraseMode={() => {}}
522-
viewOptions={{
523-
hideInactiveLinkButtons: false,
524-
simplifyPhrases: false,
525-
chapterLabelInVerse: false,
526-
showMorphology: false,
527-
showFreeTranslation: false,
528-
}}
523+
viewOptions={{ ...allFalseViewOptions }}
529524
/>,
530525
),
531526
);
@@ -635,13 +630,7 @@ describe('Interlinearizer', () => {
635630
analysisLanguage="und"
636631
phraseMode={{ kind: 'view' }}
637632
setPhraseMode={() => {}}
638-
viewOptions={{
639-
hideInactiveLinkButtons: false,
640-
simplifyPhrases: false,
641-
chapterLabelInVerse: false,
642-
showMorphology: false,
643-
showFreeTranslation: false,
644-
}}
633+
viewOptions={{ ...allFalseViewOptions }}
645634
/>,
646635
),
647636
);
@@ -675,13 +664,7 @@ describe('Interlinearizer', () => {
675664
analysisLanguage="und"
676665
phraseMode={{ kind: 'view' }}
677666
setPhraseMode={() => {}}
678-
viewOptions={{
679-
hideInactiveLinkButtons: false,
680-
simplifyPhrases: false,
681-
chapterLabelInVerse: false,
682-
showMorphology: false,
683-
showFreeTranslation: false,
684-
}}
667+
viewOptions={{ ...allFalseViewOptions }}
685668
/>,
686669
),
687670
);
@@ -720,13 +703,7 @@ describe('Interlinearizer', () => {
720703
analysisLanguage="und"
721704
phraseMode={{ kind: 'view' }}
722705
setPhraseMode={() => {}}
723-
viewOptions={{
724-
hideInactiveLinkButtons: false,
725-
simplifyPhrases: false,
726-
chapterLabelInVerse: false,
727-
showMorphology: false,
728-
showFreeTranslation: false,
729-
}}
706+
viewOptions={{ ...allFalseViewOptions }}
730707
/>,
731708
),
732709
);
@@ -742,13 +719,7 @@ describe('Interlinearizer', () => {
742719
analysisLanguage="und"
743720
phraseMode={{ kind: 'view' }}
744721
setPhraseMode={() => {}}
745-
viewOptions={{
746-
hideInactiveLinkButtons: false,
747-
simplifyPhrases: false,
748-
chapterLabelInVerse: false,
749-
showMorphology: false,
750-
showFreeTranslation: false,
751-
}}
722+
viewOptions={{ ...allFalseViewOptions }}
752723
/>,
753724
),
754725
);
@@ -789,13 +760,7 @@ describe('Interlinearizer', () => {
789760
analysisLanguage="und"
790761
phraseMode={{ kind: 'view' }}
791762
setPhraseMode={() => {}}
792-
viewOptions={{
793-
hideInactiveLinkButtons: false,
794-
simplifyPhrases: false,
795-
chapterLabelInVerse: false,
796-
showMorphology: false,
797-
showFreeTranslation: false,
798-
}}
763+
viewOptions={{ ...allFalseViewOptions }}
799764
/>,
800765
),
801766
);
@@ -830,13 +795,7 @@ describe('Interlinearizer', () => {
830795
analysisLanguage="und"
831796
phraseMode={{ kind: 'view' }}
832797
setPhraseMode={() => {}}
833-
viewOptions={{
834-
hideInactiveLinkButtons: false,
835-
simplifyPhrases: false,
836-
chapterLabelInVerse: false,
837-
showMorphology: false,
838-
showFreeTranslation: false,
839-
}}
798+
viewOptions={{ ...allFalseViewOptions }}
840799
/>,
841800
),
842801
);
@@ -930,13 +889,7 @@ describe('Interlinearizer', () => {
930889
analysisLanguage="und"
931890
phraseMode={{ kind: 'view' }}
932891
setPhraseMode={() => {}}
933-
viewOptions={{
934-
hideInactiveLinkButtons: false,
935-
simplifyPhrases: false,
936-
chapterLabelInVerse: false,
937-
showMorphology: false,
938-
showFreeTranslation: false,
939-
}}
892+
viewOptions={{ ...allFalseViewOptions }}
940893
/>,
941894
),
942895
);
@@ -959,13 +912,7 @@ describe('Interlinearizer', () => {
959912
originalTokens: [{ tokenRef: 'GEN 1:1:0', surfaceText: 'In' }],
960913
}}
961914
setPhraseMode={() => {}}
962-
viewOptions={{
963-
hideInactiveLinkButtons: false,
964-
simplifyPhrases: false,
965-
chapterLabelInVerse: false,
966-
showMorphology: false,
967-
showFreeTranslation: false,
968-
}}
915+
viewOptions={{ ...allFalseViewOptions }}
969916
/>,
970917
),
971918
);
@@ -982,13 +929,7 @@ describe('Interlinearizer', () => {
982929
analysisLanguage="und"
983930
phraseMode={{ kind: 'confirm-unlink', phraseId: 'phrase-1' }}
984931
setPhraseMode={() => {}}
985-
viewOptions={{
986-
hideInactiveLinkButtons: false,
987-
simplifyPhrases: false,
988-
chapterLabelInVerse: false,
989-
showMorphology: false,
990-
showFreeTranslation: false,
991-
}}
932+
viewOptions={{ ...allFalseViewOptions }}
992933
/>,
993934
),
994935
);
@@ -1007,13 +948,7 @@ describe('Interlinearizer', () => {
1007948
analysisLanguage="und"
1008949
phraseMode={{ kind: 'edit', phraseId: 'phrase-1', originalTokens, revert: true }}
1009950
setPhraseMode={setPhraseMode}
1010-
viewOptions={{
1011-
hideInactiveLinkButtons: false,
1012-
simplifyPhrases: false,
1013-
chapterLabelInVerse: false,
1014-
showMorphology: false,
1015-
showFreeTranslation: false,
1016-
}}
951+
viewOptions={{ ...allFalseViewOptions }}
1017952
/>,
1018953
),
1019954
);
@@ -1032,13 +967,7 @@ describe('Interlinearizer', () => {
1032967
analysisLanguage="und"
1033968
phraseMode={{ kind: 'edit', phraseId: 'phrase-1', originalTokens: [], revert: true }}
1034969
setPhraseMode={setPhraseMode}
1035-
viewOptions={{
1036-
hideInactiveLinkButtons: false,
1037-
simplifyPhrases: false,
1038-
chapterLabelInVerse: false,
1039-
showMorphology: false,
1040-
showFreeTranslation: false,
1041-
}}
970+
viewOptions={{ ...allFalseViewOptions }}
1042971
/>,
1043972
),
1044973
);
@@ -1056,13 +985,7 @@ describe('Interlinearizer', () => {
1056985
analysisLanguage: 'und',
1057986
phraseMode: { kind: 'view' } as const,
1058987
setPhraseMode: () => {},
1059-
viewOptions: {
1060-
hideInactiveLinkButtons: false,
1061-
simplifyPhrases: false,
1062-
chapterLabelInVerse: false,
1063-
showMorphology: false,
1064-
showFreeTranslation: false,
1065-
},
988+
viewOptions: { ...allFalseViewOptions },
1066989
};
1067990
const { container, rerender } = render(
1068991
withNav(
@@ -1128,13 +1051,7 @@ describe('Interlinearizer', () => {
11281051
analysisLanguage="und"
11291052
phraseMode={{ kind: 'view' }}
11301053
setPhraseMode={() => {}}
1131-
viewOptions={{
1132-
hideInactiveLinkButtons: false,
1133-
simplifyPhrases: false,
1134-
chapterLabelInVerse: false,
1135-
showMorphology: false,
1136-
showFreeTranslation: false,
1137-
}}
1054+
viewOptions={{ ...allFalseViewOptions }}
11381055
/>
11391056
);
11401057
}
@@ -1163,13 +1080,7 @@ describe('Interlinearizer', () => {
11631080
scrRef: { book: 'GEN', chapterNum: 1, verseNum: 1 },
11641081
phraseMode: { kind: 'view' } as const,
11651082
setPhraseMode: () => {},
1166-
viewOptions: {
1167-
hideInactiveLinkButtons: false,
1168-
simplifyPhrases: false,
1169-
chapterLabelInVerse: false,
1170-
showMorphology: false,
1171-
showFreeTranslation: false,
1172-
},
1083+
viewOptions: { ...allFalseViewOptions },
11731084
};
11741085
const { container, rerender } = render(
11751086
withNav(<Interlinearizer {...props} continuousScroll={false} />),

src/__tests__/components/SegmentView.test.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { LINK_SLOT_TRANSITION_MS } from '../../components/PhraseStripParts';
1212
import { SegmentView } from '../../components/SegmentView';
1313
import type { ViewOptions } from '../../types/view-options';
1414
import { makePhraseLink } from '../test-helpers';
15-
import { withAnalysisStore } from './test-helpers';
15+
import { allFalseViewOptions, withAnalysisStore } from './test-helpers';
1616

1717
// ---------------------------------------------------------------------------
1818
// AnalysisStore mock — pass-through provider so AnalysisStore.tsx stays out of scope
@@ -213,13 +213,7 @@ function requiredProps(): {
213213
tokenSegmentMap: new Map(),
214214
tokenDocOrder: new Map(),
215215
wordTokenByRef: new Map(),
216-
viewOptions: {
217-
hideInactiveLinkButtons: false,
218-
simplifyPhrases: false,
219-
chapterLabelInVerse: false,
220-
showMorphology: false,
221-
showFreeTranslation: false,
222-
},
216+
viewOptions: { ...allFalseViewOptions },
223217
};
224218
}
225219

src/__tests__/components/test-helpers.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import type { ReactNode } from 'react';
44
import { AnalysisStoreProvider } from '../../components/AnalysisStore';
5+
import { ViewOptions } from '../../types/view-options';
56

67
/**
78
* Testing Library render options that wrap a subject in `AnalysisStoreProvider` with the default
@@ -15,3 +16,12 @@ export const withAnalysisStore = {
1516
return <AnalysisStoreProvider analysisLanguage="und">{children}</AnalysisStoreProvider>;
1617
},
1718
};
19+
20+
/** A {@link ViewOptions} object with every toggle set to `false`, for use as a test baseline. */
21+
export const allFalseViewOptions: ViewOptions = {
22+
hideInactiveLinkButtons: false,
23+
simplifyPhrases: false,
24+
chapterLabelInVerse: false,
25+
showMorphology: false,
26+
showFreeTranslation: false,
27+
};

0 commit comments

Comments
 (0)