root/veekun/trunk/t/dex-pokemon.t

Revision 406, 2.5 kB (checked in by eevee, 10 months ago)

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use lib 'lib';
6
7use Test::More tests => 16;
8
9BEGIN { $ENV{CATALYST_DEBUG} = 0; }
10BEGIN { use_ok 'Catalyst::Test', 'Vee' }
11BEGIN { use_ok 'Vee::Controller::Dex' }
12
13ok 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
17my $c_eevee   = Vee->prepare;
18$c_eevee->req->args->[0] = 'eevee';
19Vee::Controller::Dex->pokemon($c_eevee);
20
21my $c_lucario = Vee->prepare;
22$c_lucario->req->args->[0] = 'lucario';
23Vee::Controller::Dex->pokemon($c_lucario);
24
25my $s_eevee   = $c_eevee->stash;
26my $s_lucario = $c_lucario->stash;
27
28is $s_eevee->{pid}, 133, "Padded id is fine";
29isa_ok $s_eevee->{this}, 'Vee::Schema::Pokemon', '$this';
30is $s_eevee->{generation}, 0, "RBY generation correct";
31is $s_lucario->{generation}, 3, "DP generation correct";
32
33is $s_eevee->{evtree}{width}, 7, "Evolution tree width is correct";
34is_deeply [ map { $_->{id} } @{$s_eevee->{evtree}{children}} ],
35    [ 134, 135, 136, 196, 197, 470, 471 ],
36    "Evolution tree children are correct";
37
38is_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
59is sprintf('%.1f', $s_eevee->{stat_average}), 54.2, "Stat average calculates correctly";
60is 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?
63isnt $s_eevee->{flavors}{d}, '', "Flavor text exists";
64# TODO
65like $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";
66ok $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.
72is $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;
Note: See TracBrowser for help on using the browser.