-
Notifications
You must be signed in to change notification settings - Fork 28
/
dialog_test.go
146 lines (140 loc) · 4.37 KB
/
dialog_test.go
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
** Mack: Alert Test
** Test desktop dialog boxes
*/
package mack
import (
"testing"
)
func TestBuildDialog(t *testing.T) {
stringAssertTests := []StringAssert{
StringAssert{
actual: buildDialog("text", []string{}),
expected: "display dialog \"text\"",
},
StringAssert{
actual: buildDialog("text", []string{"title"}),
expected: "display dialog \"text\" with title \"title\"",
},
StringAssert{
actual: buildDialog("text", []string{"title", "answer"}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\"",
},
StringAssert{
actual: buildDialog("text", []string{"title", "answer", "5"}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" giving up after 5",
},
StringAssert{
actual: buildDialog("text", []string{"", "", "5"}),
expected: "display dialog \"text\" giving up after 5",
},
}
runStringAssertTests("buildDialog", stringAssertTests, t)
}
func TestBuildDialogBox(t *testing.T) {
stringAssertTests := []StringAssert{
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
}),
expected: "display dialog \"text\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
}),
expected: "display dialog \"text\" with title \"title\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: true,
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with hidden answer",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "my-icon.icns",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon \"my-icon.icns\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "0",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon 0",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "0",
Duration: 5,
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon 0 giving up after 5",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "0",
Duration: 5,
Buttons: "Yes, No, Don't Know",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon 0 giving up after 5 " +
"buttons {\"Yes\",\"No\",\"Don't Know\"}",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "0",
Duration: 5,
Buttons: "Yes, No, Don't Know",
DefaultButton: "Don't Know",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon 0 giving up after 5 " +
"buttons {\"Yes\",\"No\",\"Don't Know\"} default button \"Don't Know\"",
},
StringAssert{
actual: buildDialogBox(DialogOptions{
Text: "text",
Title: "title",
Answer: "answer",
HiddenAnswer: false,
Icon: "0",
Duration: 5,
Buttons: "Yes, No, Don't Know, One Too Many",
DefaultButton: "Don't Know",
}),
expected: "display dialog \"text\" with title \"title\" default answer \"answer\" with icon 0 giving up after 5 " +
"buttons {\"Yes\",\"No\",\"Don't Know\"} default button \"Don't Know\"",
},
}
runStringAssertTests("buildDialogBox", stringAssertTests, t)
}