2013-09-08 14:06:48 -07:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Test::More;
|
|
|
|
use DDG::Test::Goodie;
|
|
|
|
|
2014-09-27 06:42:57 -07:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
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-',
|
2015-01-09 00:46:54 -08:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
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'],
|
2015-01-09 00:46:54 -08:00
|
|
|
operation => 'Email address validation',
|
2014-10-14 09:35:18 -07:00
|
|
|
result => qr/Please check the top-level domain/,
|
|
|
|
}
|
|
|
|
),
|
2015-07-08 17:57:28 -07:00
|
|
|
'validate foo' => undef,
|
2013-09-08 14:06:48 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|