mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 16:49:51 -07:00
feat(youtube): add mediaCache mode and safer stream media extraction (#130)
This commit is contained in:
@@ -93,3 +93,32 @@ test('select controls show config-only current values without offering them othe
|
||||
restoreDocument();
|
||||
}
|
||||
});
|
||||
|
||||
test('select controls use configured option labels', () => {
|
||||
const restoreDocument = installDocumentStub();
|
||||
try {
|
||||
const field = {
|
||||
...createSelectField(),
|
||||
enumValues: ['direct', 'background'],
|
||||
enumLabels: {
|
||||
direct: 'Direct stream extraction',
|
||||
background: 'Background media cache',
|
||||
},
|
||||
} as ConfigSettingsField & { enumLabels: Record<string, string> };
|
||||
|
||||
const control = renderControl(field, {
|
||||
valueForField: () => 'direct',
|
||||
valueForPath: () => undefined,
|
||||
updateDraft: () => {},
|
||||
resetDraftPath: () => {},
|
||||
setFieldError: () => {},
|
||||
}) as HTMLSelectElement;
|
||||
|
||||
assert.deepEqual(
|
||||
Array.from(control.options).map((option) => option.textContent),
|
||||
['Direct stream extraction', 'Background media cache'],
|
||||
);
|
||||
} finally {
|
||||
restoreDocument();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -227,7 +227,7 @@ export function renderControl(
|
||||
for (const enumValue of enumValues) {
|
||||
const option = createElement('option') as HTMLOptionElement;
|
||||
option.value = enumValue;
|
||||
option.textContent = enumValue;
|
||||
option.textContent = field.enumLabels?.[enumValue] ?? enumValue;
|
||||
option.selected = enumValue === value;
|
||||
select.append(option);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user