Ariver
2026-07-12 33f00a1136c9f7e501b989d432b709d632905304
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
43
44
45
46
47
package main
 
import (
    "testing"
 
    "voicesnap/internal/config"
)
 
func TestHotkeyReadyTextUnsetKey(t *testing.T) {
    tests := []struct {
        name string
        mode string
    }{
        {name: "hold", mode: config.HotkeyModeHold},
        {name: "tap", mode: config.HotkeyModeTap},
        {name: "unknown mode falls back to hold", mode: ""},
    }
 
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            if got := hotkeyReadyText("", tt.mode); got != "触发键未设置" {
                t.Fatalf("hotkeyReadyText(empty, %q) = %q, want unset prompt", tt.mode, got)
            }
        })
    }
}
 
func TestHotkeyReadyTextConfiguredKey(t *testing.T) {
    tests := []struct {
        name string
        key  string
        mode string
        want string
    }{
        {name: "hold", key: "R-Win", mode: config.HotkeyModeHold, want: "按住R-Win说话"},
        {name: "tap", key: "R-Win", mode: config.HotkeyModeTap, want: "点按R-Win说话"},
        {name: "unknown mode falls back to hold", key: "R-Win", mode: "", want: "按住R-Win说话"},
    }
 
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            if got := hotkeyReadyText(tt.key, tt.mode); got != tt.want {
                t.Fatalf("hotkeyReadyText(%q, %q) = %q, want %q", tt.key, tt.mode, got, tt.want)
            }
        })
    }
}