32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
import { TranscriptionOptions } from "../src/components/TranscriptionOptions";
|
|
|
|
// D-WS4a: Whisper's own "Translate to English" only where the model can do it.
|
|
function render(canTranslate: boolean): string {
|
|
return renderToStaticMarkup(
|
|
<TranscriptionOptions
|
|
language="auto"
|
|
onLanguageChange={() => {}}
|
|
task="transcribe"
|
|
onTaskChange={() => {}}
|
|
canTranslate={canTranslate}
|
|
/>,
|
|
);
|
|
}
|
|
|
|
describe("TranscriptionOptions", () => {
|
|
test("offers Translate to English when the model can translate", () => {
|
|
const html = render(true);
|
|
expect(html).toContain("Translate to English");
|
|
expect(html).toContain("Task");
|
|
});
|
|
|
|
test("hides the task control entirely when the model cannot translate", () => {
|
|
const html = render(false);
|
|
expect(html).not.toContain("Translate to English");
|
|
expect(html).not.toContain("Task");
|
|
expect(html).toContain("Language");
|
|
});
|
|
});
|