Skip to content

Commit ee8ae9d

Browse files
committed
feat(pos-make-findable): Check the box depending on whether the URI is present in the label index
1 parent 6e5284b commit ee8ae9d

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

elements/src/components/pos-make-findable/pos-make-findable.spec.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,16 @@ describe('pos-make-findable', () => {
309309
};
310310
when(mockOs.store.get).calledWith('https://thing.example#it').mockReturnValue({ fake: 'thing' });
311311
const firstIndexAssume = jest.fn();
312-
when(firstIndexAssume).calledWith(LabelIndex).mockReturnValue({ uri: 'https://pod.example/first-index' });
312+
when(firstIndexAssume)
313+
.calledWith(LabelIndex)
314+
.mockReturnValue({ uri: 'https://pod.example/first-index', contains: () => false });
313315
when(mockOs.store.get).calledWith('https://pod.example/first-index').mockReturnValue({
314316
assume: firstIndexAssume,
315317
});
316318
const secondIndexAssume = jest.fn();
317-
when(secondIndexAssume).calledWith(LabelIndex).mockReturnValue({ uri: 'https://pod.example/second-index' });
319+
when(secondIndexAssume)
320+
.calledWith(LabelIndex)
321+
.mockReturnValue({ uri: 'https://pod.example/second-index', contains: () => true });
318322
when(mockOs.store.get).calledWith('https://pod.example/second-index').mockReturnValue({
319323
assume: secondIndexAssume,
320324
});
@@ -340,20 +344,20 @@ describe('pos-make-findable', () => {
340344
expect(list).toEqualHtml(`
341345
<ol role="listbox">
342346
<li role="option">
343-
<label>
344-
<input type="checkbox">
345-
<pos-resource uri="https://pod.example/first-index" lazy>
346-
<pos-label></pos-label>
347-
</pos-resource>
348-
</label>
347+
<label>
348+
<input type="checkbox">
349+
<pos-resource uri="https://pod.example/first-index" lazy>
350+
<pos-label></pos-label>
351+
</pos-resource>
352+
</label>
349353
</li>
350354
<li role="option">
351-
<label>
352-
<input type="checkbox">
353-
<pos-resource uri="https://pod.example/second-index" lazy>
354-
<pos-label></pos-label>
355-
</pos-resource>
356-
</label>
355+
<label>
356+
<input checked type="checkbox">
357+
<pos-resource uri="https://pod.example/second-index" lazy>
358+
<pos-label></pos-label>
359+
</pos-resource>
360+
</label>
357361
</li>
358362
</ol>`);
359363
});
@@ -374,7 +378,7 @@ describe('pos-make-findable', () => {
374378
// then the thing is added to the index
375379
expect(mockOs.addToLabelIndex).toHaveBeenCalledWith(
376380
{ fake: 'thing' },
377-
{ uri: 'https://pod.example/first-index' },
381+
expect.objectContaining({ uri: 'https://pod.example/first-index' }),
378382
);
379383
await page.waitForChanges();
380384

elements/src/components/pos-make-findable/pos-make-findable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ export class PosMakeFindable implements PodOsAware {
128128
{this.indexes.map((index: LabelIndex) => (
129129
<li role="option">
130130
<label>
131-
<input type="checkbox" checked={false} onChange={e => this.chooseOption(e, index)} />
131+
<input
132+
type="checkbox"
133+
checked={index.contains(this.uri)}
134+
onChange={e => this.chooseOption(e, index)}
135+
/>
132136
<pos-resource uri={index.uri} lazy={true}>
133137
<pos-label></pos-label>
134138
</pos-resource>

0 commit comments

Comments
 (0)