Ariver
2026-07-11 015f1089ea875a153dd2a18ef42c25145d4868f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//go:build darwin
 
package input
 
import "testing"
 
func TestResolveDarwinRestoreTargetCarriesOriginalAcrossRapidPastes(t *testing.T) {
    original := darwinClipboardSnapshot{text: "user clipboard", hasText: true}
    current := darwinClipboardSnapshot{text: "first dictated text", hasText: true}
 
    got := resolveDarwinRestoreTarget(current, true, "first dictated text", original)
    if got != original {
        t.Fatalf("restore target = %+v, want original %+v", got, original)
    }
}
 
func TestResolveDarwinRestoreTargetUsesCurrentWhenClipboardChanged(t *testing.T) {
    original := darwinClipboardSnapshot{text: "user clipboard", hasText: true}
    current := darwinClipboardSnapshot{text: "external clipboard update", hasText: true}
 
    got := resolveDarwinRestoreTarget(current, true, "first dictated text", original)
    if got != current {
        t.Fatalf("restore target = %+v, want current %+v", got, current)
    }
}
 
func TestShouldRestoreDarwinClipboardRequiresCurrentGenerationAndText(t *testing.T) {
    current := darwinClipboardSnapshot{text: "dictated text", hasText: true}
 
    if !shouldRestoreDarwinClipboard(3, 3, true, "dictated text", "dictated text", current) {
        t.Fatal("expected current generation with matching clipboard to restore")
    }
 
    if shouldRestoreDarwinClipboard(4, 3, true, "dictated text", "dictated text", current) {
        t.Fatal("stale generation must not restore")
    }
 
    changed := darwinClipboardSnapshot{text: "user changed clipboard", hasText: true}
    if shouldRestoreDarwinClipboard(3, 3, true, "dictated text", "dictated text", changed) {
        t.Fatal("changed clipboard must not be overwritten")
    }
}