package preferences import ( "reflect" "testing" "git.stormux.org/storm/cthulhu/internal/config" "git.stormux.org/storm/cthulhu/internal/input" ) func TestSpeechInterruptionValuesRoundTrip(t *testing.T) { settings := config.DefaultSettings() values := FromSettings(settings) values.SpeechInterruption = input.InterruptionSettings{Mode: input.InterruptCustomKeys, Keys: []string{"Tab", "Return"}} merged, err := values.Merge(settings) if err != nil || !reflect.DeepEqual(FromSettings(merged), values) { t.Fatalf("interruption values did not round trip: %+v, %v", merged.SpeechInterruption, err) } values.SpeechInterruption.Keys[0] = "Escape" if merged.SpeechInterruption.Keys[0] != "Tab" { t.Fatal("merged settings share the UI's mutable keys") } values.SpeechInterruption.Keys = nil if _, err := values.Merge(settings); err == nil { t.Fatal("accepted custom mode without keys") } }