zeroclickinfo-goodies/t/EmailValidator.t

74 lines
2.5 KiB
Perl
Raw Normal View History

2013-09-08 14:06:48 -07:00
#! /usr/bin/env perl
use strict;
use warnings;
use Test::More;
use DDG::Test::Goodie;
zci answer_type => 'email_validation';
zci is_cached => 1;
2013-09-08 14:06:48 -07:00
ddg_goodie_test(
2014-10-14 09:35:18 -07:00
['DDG::Goodie::EmailValidator'],
'validate my email foo@example.com' => test_zci(
qr/appears to be valid/,
structured_answer => {
input => ['foo@example.com'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/appears to be valid/
}
),
'validate my email foo+abc@example.com' => test_zci(
qr/appears to be valid/,
structured_answer => {
input => ['foo+abc@example.com'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/appears to be valid/
}
),
'validate my email foo.bar@example.com' => test_zci(
qr/appears to be valid/,
structured_answer => {
input => ['foo.bar@example.com'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/appears to be valid/
}
),
'validate user@exampleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.com'
=> test_zci(
qr/Please check the address/,
structured_answer => {
input => '-ANY-',
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/Please check the address/,
}
),
'validate foo@example.com' => test_zci(
qr/appears to be valid/,
structured_answer => {
input => ['foo@example.com'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/appears to be valid/
}
),
'validate foo@!!!.com' => test_zci(
qr/Please check the fully qualified domain name/,
structured_answer => {
input => ['foo@!!!.com'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/Please check the fully qualified domain name/,
}
),
'validate foo@example.lmnop' => test_zci(
qr/Please check the top-level domain/,
structured_answer => {
input => ['foo@example.lmnop'],
operation => 'Email address validation',
2014-10-14 09:35:18 -07:00
result => qr/Please check the top-level domain/,
}
),
'validate foo' => undef,
2013-09-08 14:06:48 -07:00
);
done_testing;