| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use lib 'lib'; |
|---|
| 6 | |
|---|
| 7 | use Test::More tests => 16; |
|---|
| 8 | |
|---|
| 9 | BEGIN { $ENV{CATALYST_DEBUG} = 0; } |
|---|
| 10 | BEGIN { use_ok 'Catalyst::Test', 'Vee' } |
|---|
| 11 | BEGIN { use_ok 'Vee::Controller::Dex' } |
|---|
| 12 | |
|---|
| 13 | ok request('/dex/pokemon/latias')->is_success, "Pokemon page loads"; |
|---|
| 14 | |
|---|
| 15 | # To make this (fairly) simply, I'll do most tests on an RBY Pokemon (me!) and a |
|---|
| 16 | # handful of generational tests on a DP Pokemon |
|---|
| 17 | my $c_eevee = Vee->prepare; |
|---|
| 18 | $c_eevee->req->args->[0] = 'eevee'; |
|---|
| 19 | Vee::Controller::Dex->pokemon($c_eevee); |
|---|
| 20 | |
|---|
| 21 | my $c_lucario = Vee->prepare; |
|---|
| 22 | $c_lucario->req->args->[0] = 'lucario'; |
|---|
| 23 | Vee::Controller::Dex->pokemon($c_lucario); |
|---|
| 24 | |
|---|
| 25 | my $s_eevee = $c_eevee->stash; |
|---|
| 26 | my $s_lucario = $c_lucario->stash; |
|---|
| 27 | |
|---|
| 28 | is $s_eevee->{pid}, 133, "Padded id is fine"; |
|---|
| 29 | isa_ok $s_eevee->{this}, 'Vee::Schema::Pokemon', '$this'; |
|---|
| 30 | is $s_eevee->{generation}, 0, "RBY generation correct"; |
|---|
| 31 | is $s_lucario->{generation}, 3, "DP generation correct"; |
|---|
| 32 | |
|---|
| 33 | is $s_eevee->{evtree}{width}, 7, "Evolution tree width is correct"; |
|---|
| 34 | is_deeply [ map { $_->{id} } @{$s_eevee->{evtree}{children}} ], |
|---|
| 35 | [ 134, 135, 136, 196, 197, 470, 471 ], |
|---|
| 36 | "Evolution tree children are correct"; |
|---|
| 37 | |
|---|
| 38 | is_deeply $s_eevee->{type_effects}, { |
|---|
| 39 | bug => 100, |
|---|
| 40 | dark => 100, |
|---|
| 41 | dragon => 100, |
|---|
| 42 | electric => 100, |
|---|
| 43 | fighting => 200, |
|---|
| 44 | fire => 100, |
|---|
| 45 | flying => 100, |
|---|
| 46 | ghost => 0, |
|---|
| 47 | grass => 100, |
|---|
| 48 | ground => 100, |
|---|
| 49 | ice => 100, |
|---|
| 50 | normal => 100, |
|---|
| 51 | poison => 100, |
|---|
| 52 | psychic => 100, |
|---|
| 53 | rock => 100, |
|---|
| 54 | steel => 100, |
|---|
| 55 | water => 100, |
|---|
| 56 | }, "Type effects correct"; |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | is sprintf('%.1f', $s_eevee->{stat_average}), 54.2, "Stat average calculates correctly"; |
|---|
| 60 | is sprintf('%.1f', $s_eevee->{stat_percentiles}{average}), 27.4, "Stat average percentile calculates correctly"; |
|---|
| 61 | |
|---|
| 62 | # XXX: I guess not all the flavor text is really needed any more? |
|---|
| 63 | isnt $s_eevee->{flavors}{d}, '', "Flavor text exists"; |
|---|
| 64 | # TODO |
|---|
| 65 | like $s_eevee->{flavors}{d}, qr/^A rare Pok.{1,3}mon that adapts to harsh environments by taking on different evolutionary forms\.$/, "Flavor text is correct, ignoring the accent"; |
|---|
| 66 | ok $s_eevee->{flavors}{d} eq $s_eevee->{flavors}{p}, "Diamond and Pearl flavor text is identical"; |
|---|
| 67 | |
|---|
| 68 | # TODO: Test locations once those are figured out |
|---|
| 69 | |
|---|
| 70 | # TODO: Any way to flesh these out without just doing one big is_deeply? |
|---|
| 71 | # These are just spot checks for arbitrary moves. |
|---|
| 72 | is $s_eevee->{moves}{level}[-1]{move_id}, 376, "Eevee's last move is Trump Card"; |
|---|
| 73 | |
|---|
| 74 | #use Data::Dumper; $Data::Dumper::Maxdepth = 3; warn Dumper $s_eevee; |
|---|