Skip to content

Commit

Permalink
Add a few more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
percivalalb authored and Alex Barter committed Nov 16, 2023
1 parent e5bbd8d commit b41ef0b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions t/timezones.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ use warnings;
use lib 't/inc';
use nptestutils;

use Number::Phone;
use Number::Phone::Lib;
use Number::Phone::NANP;
use Test::More;

my %tests = (
'+442087712924' => ['Europe/London'],
'+445511000000' => ['Europe/Guernsey', 'Europe/Isle_of_Man', 'Europe/Jersey', 'Europe/London'],
'+12024181440' => ['America/New_York'],
'+81335803311' => ['Asia/Tokyo'],
'+18885558888' => [split('&', 'America/Adak&America/Anchorage&America/Anguilla&America/Antigua&America/Barbados&America/Boise&America/Cayman&America/Chicago&America/Denver&America/Dominica&America/Edmonton&America/Fort_Nelson&America/Grand_Turk&America/Grenada&America/Halifax&America/Jamaica&America/Juneau&America/Los_Angeles&America/Lower_Princes&America/Montserrat&America/Nassau&America/New_York&America/North_Dakota/Center&America/Phoenix&America/Port_of_Spain&America/Puerto_Rico&America/Regina&America/Santo_Domingo&America/St_Johns&America/St_Kitts&America/St_Lucia&America/St_Thomas&America/St_Vincent&America/Toronto&America/Tortola&America/Vancouver&America/Winnipeg&Atlantic/Bermuda&Pacific/Guam&Pacific/Honolulu&Pacific/Pago_Pago&Pacific/Saipan')], # Non-geographic NANP number.
'+442087712924' => ['Europe/London'], # Geographic UK number
'+445511000000' => ['Europe/Guernsey','Europe/Isle_of_Man','Europe/Jersey','Europe/London'], # Non-geographic UK number
'+12024181440' => ['America/New_York'], # geographic New York number
'+18765551234' => ['America/Jamaica'], # geographic Jamaican number
'+81335803311' => ['Asia/Tokyo'], # geographic Japanese number
'+815012345678' => ['Asia/Tokyo'], # non-geographic Japanese number
'+18885558888' => ['America/Adak','America/Anchorage','America/Anguilla','America/Antigua','America/Barbados','America/Boise','America/Cayman','America/Chicago','America/Denver','America/Dominica','America/Edmonton','America/Fort_Nelson','America/Grand_Turk','America/Grenada','America/Halifax','America/Jamaica','America/Juneau','America/Los_Angeles','America/Lower_Princes','America/Montserrat','America/Nassau','America/New_York','America/North_Dakota/Center','America/Phoenix','America/Port_of_Spain','America/Puerto_Rico','America/Regina','America/Santo_Domingo','America/St_Johns','America/St_Kitts','America/St_Lucia','America/St_Thomas','America/St_Vincent','America/Toronto','America/Tortola','America/Vancouver','America/Winnipeg','Atlantic/Bermuda','Pacific/Guam','Pacific/Honolulu','Pacific/Pago_Pago','Pacific/Saipan'], # Non-geographic NANP number.
);

note("timezones()");
Expand All @@ -20,4 +24,9 @@ while (my ($num, $expect) = each %tests) {
is_deeply($number->timezones(), $expect, "timezone of $num using libphonenumber");
}

# Non-stubs do not implement timezones() and always should return undef
# even if libnumberphone has data.
is(Number::Phone->new('+18885558888')->timezones(), undef, 'non-stubs return undef');
is(Number::Phone::NANP->new('+12024181440')->timezones(), undef, 'non-no stubs return undef');

done_testing();

0 comments on commit b41ef0b

Please sign in to comment.