Skip to content

Commit a2c253d

Browse files
author
Matt Rogers
committed
Add extra validator test cases
1 parent 4dde390 commit a2c253d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validator_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ func TestValidatorSingleDomain(t *testing.T) {
9595
if !validator("[email protected]") {
9696
t.Error("email from same domain should validate")
9797
}
98+
if validator("[email protected]") {
99+
t.Error("email from not listed domain should not validate")
100+
}
98101
}
99102

100103
func TestValidatorMultipleEmailsMultipleDomains(t *testing.T) {
@@ -160,3 +163,19 @@ func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
160163
t.Error("email should validate")
161164
}
162165
}
166+
167+
func TestValidatorWildcardDomain(t *testing.T) {
168+
vt := NewValidatorTest(t)
169+
defer vt.TearDown()
170+
171+
vt.WriteEmails(t, []string(nil))
172+
domains := []string{"*"}
173+
validator := vt.NewValidator(domains, nil)
174+
175+
if !validator("[email protected]") {
176+
t.Error("wildcard domain should validate any email")
177+
}
178+
if !validator("[email protected]") {
179+
t.Error("wildcard domain should validate any email")
180+
}
181+
}

0 commit comments

Comments
 (0)