@@ -110,3 +110,120 @@ func TestGetGinkgoHandler_no_ginkgo(t *testing.T) {
110
110
t .Fatalf ("should return nil" )
111
111
}
112
112
}
113
+
114
+ func TestDotHandler_GetFocusContainerName_happy (t * testing.T ) {
115
+ exp := & ast.CallExpr {
116
+ Fun : ast .NewIdent ("FIt" ),
117
+ }
118
+
119
+ h := dotHandler {}
120
+
121
+ isFocus , name := h .GetFocusContainerName (exp )
122
+
123
+ if ! isFocus {
124
+ t .Error ("h.GetFocusContainerName(exp) should return true" )
125
+ }
126
+
127
+ if name == nil {
128
+ t .Error ("should return valid ast.Ident object" )
129
+ } else if name .Name != "FIt" {
130
+ t .Error ("function name should be 'FIt'" )
131
+ }
132
+ }
133
+
134
+ func TestDotHandler_GetFocusContainerName_no_focus (t * testing.T ) {
135
+ exp := & ast.CallExpr {
136
+ Fun : ast .NewIdent ("It" ),
137
+ }
138
+
139
+ h := dotHandler {}
140
+ isFocus , name := h .GetFocusContainerName (exp )
141
+ if isFocus {
142
+ t .Error ("h.GetFocusContainerName(exp) should return false" )
143
+ }
144
+
145
+ if name == nil {
146
+ t .Error ("should return valid ast.Ident object" )
147
+ } else if name .Name != "It" {
148
+ t .Error ("function name should be 'It'" )
149
+ }
150
+ }
151
+
152
+ func TestDotHandler_GetFocusContainerName_selector (t * testing.T ) {
153
+ exp := & ast.CallExpr {
154
+ Fun : & ast.SelectorExpr {
155
+ Sel : ast .NewIdent ("ginkgo" ),
156
+ X : & ast.CallExpr {
157
+ Fun : ast .NewIdent ("FIt" ),
158
+ },
159
+ },
160
+ }
161
+
162
+ h := dotHandler {}
163
+ isFocus , name := h .GetFocusContainerName (exp )
164
+ if isFocus {
165
+ t .Error ("h.GetFocusContainerName(exp) should return false" )
166
+ }
167
+
168
+ if name != nil {
169
+ t .Error ("should return nil" )
170
+ }
171
+ }
172
+
173
+ func TestNameHandler_GetFocusContainerName_happy (t * testing.T ) {
174
+ exp := & ast.CallExpr {
175
+ Fun : & ast.SelectorExpr {
176
+ Sel : ast .NewIdent ("FIt" ),
177
+ X : ast .NewIdent ("ginkgo" ),
178
+ },
179
+ }
180
+
181
+ h := nameHandler ("ginkgo" )
182
+ isFocus , name := h .GetFocusContainerName (exp )
183
+ if ! isFocus {
184
+ t .Error ("h.GetFocusContainerName(exp) should return true" )
185
+ }
186
+
187
+ if name == nil {
188
+ t .Error ("should return a valid ast.Ident object" )
189
+ } else if name .Name != "FIt" {
190
+ t .Error ("function name should be 'FIt'" )
191
+ }
192
+ }
193
+
194
+ func TestNameHandler_GetFocusContainerName_no_focus (t * testing.T ) {
195
+ exp := & ast.CallExpr {
196
+ Fun : & ast.SelectorExpr {
197
+ Sel : ast .NewIdent ("It" ),
198
+ X : ast .NewIdent ("ginkgo" ),
199
+ },
200
+ }
201
+
202
+ h := nameHandler ("ginkgo" )
203
+ isFocus , name := h .GetFocusContainerName (exp )
204
+ if isFocus {
205
+ t .Error ("h.GetFocusContainerName(exp) should return false" )
206
+ }
207
+
208
+ if name == nil {
209
+ t .Error ("should return a valid ast.Ident object" )
210
+ } else if name .Name != "It" {
211
+ t .Error ("function name should be 'FIt'" )
212
+ }
213
+ }
214
+
215
+ func TestNameHandler_GetFocusContainerName_ident (t * testing.T ) {
216
+ exp := & ast.CallExpr {
217
+ Fun : ast .NewIdent ("FIt" ),
218
+ }
219
+
220
+ h := nameHandler ("ginkgo" )
221
+ isFocus , name := h .GetFocusContainerName (exp )
222
+ if isFocus {
223
+ t .Error ("h.GetFocusContainerName(exp) should return false" )
224
+ }
225
+
226
+ if name != nil {
227
+ t .Error ("should return nil" )
228
+ }
229
+ }
0 commit comments