summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-10-14 23:54:04 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-10-14 23:54:04 +0200
commit48a14373db07a1b1556b2a8d176eb851cd2bd44a (patch)
tree2cf276e14a62025c4e583e2ef0fe50c7fb590957
parentfca9e64d1a70ced8aedfaeb5a5614122c8fdd55d (diff)
more tests
-rw-r--r--t/23-results.t13
-rw-r--r--t/24-results-route.t24
2 files changed, 34 insertions, 3 deletions
diff --git a/t/23-results.t b/t/23-results.t
index d4f6896..9701603 100644
--- a/t/23-results.t
+++ b/t/23-results.t
@@ -5,7 +5,7 @@ use 5.010;
use utf8;
use List::Util qw(first);
-use Test::More tests => 10;
+use Test::More tests => 18;
BEGIN {
use_ok('Travel::Status::DE::URA');
@@ -40,3 +40,14 @@ is($results[0]->date, '23.12.2013', '->date');
isa_ok($results[0]->datetime, 'DateTime', '->datetime is DateTime');
is($results[0]->time, '12:44:00', '->time');
is($results[0]->type, 'Bus', '->type');
+
+# same-ish for TO_JSON
+
+isa_ok($results[0]->TO_JSON->{datetime}, 'DateTime', 'TO_JSON.datetime isa DateTime');
+is($results[0]->TO_JSON->{datetime}->strftime('%Y%m%d%H%M%S'), '20131223124400', 'TO_JSON.datetime');
+is($results[0]->TO_JSON->{datetime}, $results[0]->datetime, 'TO_JSON.datetime');
+is($results[0]->TO_JSON->{destination}, $results[0]->destination, 'TO_JSON.destination');
+is($results[0]->TO_JSON->{line}, $results[0]->line, 'TO_JSON.line');
+is($results[0]->TO_JSON->{line_id}, $results[0]->line_id, 'TO_JSON.line_id');
+is($results[0]->TO_JSON->{stop}, $results[0]->stop, 'TO_JSON.stop');
+is($results[0]->TO_JSON->{stop_id}, $results[0]->stop_id, 'TO_JSON.stop_id');
diff --git a/t/24-results-route.t b/t/24-results-route.t
index 9d430c9..f72ffa6 100644
--- a/t/24-results-route.t
+++ b/t/24-results-route.t
@@ -4,9 +4,8 @@ use warnings;
use 5.010;
use utf8;
-use Data::Dumper;
use List::Util qw(first);
-use Test::More tests => 17;
+use Test::More tests => 32;
BEGIN {
use_ok('Travel::Status::DE::URA');
@@ -54,3 +53,24 @@ is(($results[0]->route_post)[2]->name, 'Gesundheitsamt', '->route_post[2]->name'
is(($results[0]->route_post)[0]->TO_JSON->{datetime}, ($results[0]->route_post)[0]->datetime, 'TO_JSON.datetime');
is(($results[0]->route_post)[0]->TO_JSON->{name}, ($results[0]->route_post)[0]->name, 'TO_JSON.name');
+
+isa_ok(($results[1]->route_interesting)[0], 'Travel::Status::DE::URA::Stop',
+ '->route_interesting isa ::Stop');
+is(scalar $results[1]->route_interesting(1), 1, '->route_interesting(1) returns one element');
+is(scalar $results[1]->route_interesting(2), 2, '->route_interesting(2) returns two elements');
+ is(scalar $results[1]->route_interesting, 3, '->route_interesting() returns hree elements');
+is(scalar $results[1]->route_interesting(4), 4, '->route_interesting(4) returns four elements');
+
+is(($results[1]->route_interesting(1))[0]->name, 'Weststraße', '->route_interesting[0] is next');
+is(($results[1]->route_interesting(2))[0]->name, 'Weststraße', '->route_interesting[0] is next');
+is(($results[1]->route_interesting)[0]->name, 'Weststraße', '->route_interesting[0] is next');
+is(($results[1]->route_interesting(4))[0]->name, 'Weststraße', '->route_interesting[0] is next');
+
+is(($results[1]->route_interesting(2))[1]->name, 'Aachen Bushof', '->route_interesting[1]');
+is(($results[1]->route_interesting)[1]->name, 'Aachen Bushof', '->route_interesting[1]');
+is(($results[1]->route_interesting(4))[1]->name, 'Technologiepark', '->route_interesting[1] (no more important stops)');
+
+is(($results[1]->route_interesting)[2]->name, 'Bahnhof Rothe Erde', '->route_interesting[2]');
+is(($results[1]->route_interesting(4))[2]->name, 'Aachen Bushof', '->route_interesting[2]');
+
+is(($results[1]->route_interesting(4))[3]->name, 'Bahnhof Rothe Erde', '->route_interesting[3]');