Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots πŸ“–

test(voice): cover what a microphone permission result should trigger

Luis Ortiz3bc9bdc62b18
diff --git a/src/entrypoints/background/__tests__/permission-outcome.test.ts b/src/entrypoints/background/__tests__/permission-outcome.test.ts
new file mode 100644
index 0000000..ec4d2f8
--- /dev/null
+++ b/src/entrypoints/background/__tests__/permission-outcome.test.ts
@@ -0,0 +1,32 @@
+import { describe, expect, it } from 'vitest';
+import { permissionOutcome } from '../voice';
+
+describe('permissionOutcome', () => {
+ it('starts narration once access is granted while a recording waits for it', () => {
+ expect(permissionOutcome('granted', 'error')).toBe('start');
+ });
+
+ it('starts narration when access is granted and nothing has failed yet', () => {
+ expect(permissionOutcome('granted', 'idle')).toBe('start');
+ });
+
+ it('leaves a running capture alone when access is granted again', () => {
+ expect(permissionOutcome('granted', 'recording')).toBe('ignore');
+ });
+
+ it('leaves a transcribing take alone when access is granted again', () => {
+ expect(permissionOutcome('granted', 'transcribing')).toBe('ignore');
+ });
+
+ it('says why narration will not run when access is refused', () => {
+ expect(permissionOutcome('denied', 'idle')).toBe('report-denied');
+ });
+
+ it('says why even when an earlier attempt already failed', () => {
+ expect(permissionOutcome('denied', 'error')).toBe('report-denied');
+ });
+
+ it('does not interrupt a running capture when a stale refusal arrives', () => {
+ expect(permissionOutcome('denied', 'recording')).toBe('ignore');
+ });
+});