Skip to content

Commit a50d6cd

Browse files
Minor adjustments
1 parent e6dd6f4 commit a50d6cd

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

src/__tests__/components/controls/ViewOptionsDropdown.test.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ describe('ViewOptionsDropdown', () => {
126126
render(<ViewOptionsDropdown {...DEFAULT_PROPS} continuousScroll />);
127127
await userEvent.click(screen.getByTestId('view-options-button'));
128128

129-
const checkboxes = screen.getAllByRole('checkbox');
130-
expect(checkboxes[0]).toBeChecked();
129+
expect(screen.getByRole('checkbox', { name: /continuousScroll/i })).toBeChecked();
131130
});
132131

133132
it('calls onContinuousScrollChange when toggled', async () => {
@@ -141,8 +140,7 @@ describe('ViewOptionsDropdown', () => {
141140
);
142141
await userEvent.click(screen.getByTestId('view-options-button'));
143142

144-
const checkboxes = screen.getAllByRole('checkbox');
145-
await userEvent.click(checkboxes[0]);
143+
await userEvent.click(screen.getByRole('checkbox', { name: /continuousScroll/i }));
146144

147145
expect(onContinuousScrollChange).toHaveBeenCalledWith(true);
148146
});
@@ -203,8 +201,7 @@ describe('ViewOptionsDropdown', () => {
203201
render(<ViewOptionsDropdown {...DEFAULT_PROPS} hideInactiveLinkButtons />);
204202
await userEvent.click(screen.getByTestId('view-options-button'));
205203

206-
const checkboxes = screen.getAllByRole('checkbox');
207-
expect(checkboxes[3]).toBeChecked();
204+
expect(screen.getByRole('checkbox', { name: /hideInactiveLinkButtons/i })).toBeChecked();
208205
});
209206

210207
it('calls onHideInactiveLinkButtonsChange when toggled', async () => {
@@ -218,8 +215,7 @@ describe('ViewOptionsDropdown', () => {
218215
);
219216
await userEvent.click(screen.getByTestId('view-options-button'));
220217

221-
const checkboxes = screen.getAllByRole('checkbox');
222-
await userEvent.click(checkboxes[3]);
218+
await userEvent.click(screen.getByRole('checkbox', { name: /hideInactiveLinkButtons/i }));
223219

224220
expect(onHideInactiveLinkButtonsChange).toHaveBeenCalledWith(true);
225221
});
@@ -230,8 +226,7 @@ describe('ViewOptionsDropdown', () => {
230226
render(<ViewOptionsDropdown {...DEFAULT_PROPS} simplifyPhrases />);
231227
await userEvent.click(screen.getByTestId('view-options-button'));
232228

233-
const checkboxes = screen.getAllByRole('checkbox');
234-
expect(checkboxes[4]).toBeChecked();
229+
expect(screen.getByRole('checkbox', { name: /simplifyPhrases/i })).toBeChecked();
235230
});
236231

237232
it('calls onSimplifyPhrasesChange when toggled', async () => {
@@ -245,8 +240,7 @@ describe('ViewOptionsDropdown', () => {
245240
);
246241
await userEvent.click(screen.getByTestId('view-options-button'));
247242

248-
const checkboxes = screen.getAllByRole('checkbox');
249-
await userEvent.click(checkboxes[4]);
243+
await userEvent.click(screen.getByRole('checkbox', { name: /simplifyPhrases/i }));
250244

251245
expect(onSimplifyPhrasesChange).toHaveBeenCalledWith(true);
252246
});
@@ -257,8 +251,7 @@ describe('ViewOptionsDropdown', () => {
257251
render(<ViewOptionsDropdown {...DEFAULT_PROPS} chapterLabelInVerse />);
258252
await userEvent.click(screen.getByTestId('view-options-button'));
259253

260-
const checkboxes = screen.getAllByRole('checkbox');
261-
expect(checkboxes[5]).toBeChecked();
254+
expect(screen.getByRole('checkbox', { name: /chapterLabelInVerse/i })).toBeChecked();
262255
});
263256

264257
it('calls onChapterLabelInVerseChange when toggled', async () => {
@@ -272,8 +265,7 @@ describe('ViewOptionsDropdown', () => {
272265
);
273266
await userEvent.click(screen.getByTestId('view-options-button'));
274267

275-
const checkboxes = screen.getAllByRole('checkbox');
276-
await userEvent.click(checkboxes[5]);
268+
await userEvent.click(screen.getByRole('checkbox', { name: /chapterLabelInVerse/i }));
277269

278270
expect(onChapterLabelInVerseChange).toHaveBeenCalledWith(true);
279271
});

src/__tests__/main.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,22 @@ describe('main', () => {
271271
);
272272
});
273273

274-
it('adds all registrations to the activation context', async () => {
274+
it('adds every created registration to the activation context for disposal', async () => {
275275
const context = createTestActivationContext();
276276

277277
await activate(context);
278278

279-
expect(context.registrations.unsubscribers.size).toBe(24);
279+
// Every registration produced during activation must be handed to the context so the platform
280+
// disposes it on deactivation: the WebView provider, one per command and validator, plus the
281+
// two WebView lifecycle subscriptions. Deriving the count from the mock calls keeps this
282+
// resilient when commands or validators are added or removed.
283+
const expectedRegistrationCount =
284+
__mockRegisterWebViewProvider.mock.calls.length +
285+
__mockRegisterCommand.mock.calls.length +
286+
__mockRegisterValidator.mock.calls.length +
287+
__mockOnDidOpenWebView.mock.calls.length +
288+
__mockOnDidCloseWebView.mock.calls.length;
289+
expect(context.registrations.unsubscribers.size).toBe(expectedRegistrationCount);
280290
});
281291

282292
it('logs activation start and finish', async () => {

src/components/SegmentView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ type SegmentViewProps = Readonly<{
110110
* @param props.wordTokenByRef - Word token ref → token lookup; used to resolve focus context.
111111
* @param props.viewOptions - Bundled display toggles; `chapterLabelInVerse` sets the verse label,
112112
* the rest pass through to the phrase strip context.
113-
* @returns A button (baseline-text mode) or div (token-chip mode) containing a verse label and
114-
* segment content
113+
* @returns A div containing a verse label and the segment content (baseline text or token chips)
115114
*/
116115
export function SegmentView({
117116
displayMode,

0 commit comments

Comments
 (0)