Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

test(desktop): cover transcription hint normalization

Richie McIlroy37de84b76616
diff --git a/apps/desktop/src/utils/general-settings.test.ts b/apps/desktop/src/utils/general-settings.test.ts
new file mode 100644
index 000000000..18740953a
--- /dev/null
+++ b/apps/desktop/src/utils/general-settings.test.ts
@@ -0,0 +1,62 @@
+import { describe, expect, it } from "vitest";
+
+import {
+ DEFAULT_TRANSCRIPTION_HINTS,
+ deriveGeneralSettings,
+ formatTranscriptionHints,
+ normalizeTranscriptionHints,
+ parseTranscriptionHints,
+} from "~/utils/general-settings";
+
+describe("general-settings", () => {
+ it("normalizes transcription hints from text input", () => {
+ expect(
+ parseTranscriptionHints(" Cap \n\nTypeScript\nCap\nGitHub\n"),
+ ).toEqual(["Cap", "TypeScript", "GitHub"]);
+ });
+
+ it("formats transcription hints for the textarea", () => {
+ expect(formatTranscriptionHints(["Cap", "TypeScript", "Cap"])).toBe(
+ "Cap\nTypeScript",
+ );
+ });
+
+ it("normalizes transcription hints from a list", () => {
+ expect(
+ normalizeTranscriptionHints([" Cap ", "", "TypeScript", "Cap", "GitHub"]),
+ ).toEqual(["Cap", "TypeScript", "GitHub"]);
+ });
+
+ it("defaults transcription hints when missing", () => {
+ expect(deriveGeneralSettings(null).transcriptionHints).toEqual(
+ DEFAULT_TRANSCRIPTION_HINTS,
+ );
+ });
+
+ it("defaults recording enhancements to enabled when missing", () => {
+ expect(
+ deriveGeneralSettings({
+ enableNativeCameraPreview: false,
+ }),
+ ).toMatchObject({
+ autoZoomOnClicks: true,
+ captureKeyboardEvents: true,
+ custom_cursor_capture2: true,
+ });
+ });
+
+ it("preserves explicit disabled recording enhancements", () => {
+ expect(
+ deriveGeneralSettings({
+ enableNativeCameraPreview: false,
+ autoZoomOnClicks: false,
+ captureKeyboardEvents: false,
+ custom_cursor_capture2: false,
+ }),
+ ).toMatchObject({
+ autoZoomOnClicks: false,
+ captureKeyboardEvents: false,
+ custom_cursor_capture2: false,
+ });
+ });
+});