2022-02-17 20:12:51 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe EmailAddressValidator do
|
2022-02-17 20:12:51 -05:00
|
|
|
it "should match valid emails" do
|
2023-01-09 06:18:21 -05:00
|
|
|
%w[
|
2022-02-17 20:12:51 -05:00
|
|
|
test@discourse.org
|
|
|
|
good_user@discourse.org
|
|
|
|
incoming+%{reply_key}@discourse.org
|
|
|
|
].each { |email| expect(EmailAddressValidator.valid_value?(email)).to eq(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should not match invalid emails" do
|
|
|
|
[
|
|
|
|
"testdiscourse.org",
|
|
|
|
"frank@invalid_host.contoso.com",
|
|
|
|
"frank@invalid_host.com",
|
|
|
|
"test@discourse.org; a@discourse.org",
|
|
|
|
"random",
|
2023-01-09 06:18:21 -05:00
|
|
|
"",
|
2022-02-17 20:12:51 -05:00
|
|
|
].each { |email| expect(EmailAddressValidator.valid_value?(email)).to eq(false) }
|
|
|
|
end
|
|
|
|
end
|