File: prompt_test.go

package info (click to toggle)
pat 0.19.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,228 kB
  • sloc: javascript: 3,864; sh: 147; makefile: 11
file content (37 lines) | stat: -rw-r--r-- 754 bytes parent folder | download | duplicates (2)
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
package forms

import (
	"fmt"
	"testing"
)

func TestReplaceSelect(t *testing.T) {
	tests := []struct {
		In, Expect string
		Answer     func(Select) Option
	}{
		{
			In:     "",
			Expect: "",
			Answer: nil,
		},
		{
			In:     "foobar",
			Expect: "foobar",
			Answer: nil,
		},
		{
			In:     `Subj: //WL2K <Select Prioritet:,Routine=R/,Priority=P/,Immediate=O/,Flash=Z/> <Callsign>/<SeqNum> - <Var Subject>`,
			Expect: `Subj: //WL2K R/ <Callsign>/<SeqNum> - <Var Subject>`,
			Answer: func(s Select) Option { return s.Options[0] },
		},
	}
	for i, tt := range tests {
		t.Run(fmt.Sprint(i), func(t *testing.T) {
			got := promptSelects(tt.In, tt.Answer)
			if got != tt.Expect {
				t.Errorf("Expected %q, got %q", tt.Expect, got)
			}
		})
	}
}