[Bps-public-commit] r11296 - WebChart/t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Mon Mar 31 08:50:06 EDT 2008


Author: sunnavy
Date: Mon Mar 31 08:49:49 2008
New Revision: 11296

Added:
   WebChart/t/plotkit.t

Log:
added tests for plotkit renderer

Added: WebChart/t/plotkit.t
==============================================================================
--- (empty file)
+++ WebChart/t/plotkit.t	Mon Mar 31 08:49:49 2008
@@ -0,0 +1,71 @@
+use strict;
+use warnings;
+
+use lib 't/lib';
+use Test::More tests => 16;
+use WebChart::Renderer::PlotKit;
+
+my $renderer = WebChart::Renderer::PlotKit->new;
+isa_ok( $renderer, 'WebChart::Renderer::PlotKit' );
+
+my $data = [
+    [ '2004', '2005', '2006', '2007' ],    # labels
+    [ 14,     15,     17,     22 ],        # first data set
+    [ 22,     25,     20,     21 ],        # second data set
+];
+
+my ( $seg, $id ) = $renderer->render(
+    type => 'bars',
+    data => $data,
+);
+
+like( $id,  qr/^\d{6}$/,  'id is a number with 6 digits' );
+like( $seg, qr/id="$id"/, '$seg contains correct $id' );
+
+like( $seg, qr{src="/js/plotkit/}, 'default js dir is /js' );
+
+for (qw/Base Layout Canvas SweetCanvas/) {
+    like( $seg, qr{src="/js/plotkit/$_.js}, "found plotkit/$_.js" );
+}
+
+like( $seg, qr{src="/js/mochikit/MochiKit.js"}, 'found mochikit/MochiKit.js' );
+
+like( $seg, qr{width="400"}, 'default width is 400' );
+
+like( $seg, qr{height="300"}, 'default height is 300' );
+
+$seg = $renderer->render(
+    type        => 'bars',
+    data        => $data,
+    width       => 800,
+    height      => 600,
+    web_js_dir => '/jsjsjs',
+    web_css_class => 'foo bar',
+);
+
+like( $seg, qr{src="/jsjsjs/plotkit/}, 'web_js_dir works' );
+like(
+    $seg,
+    qr{width="800"},
+    'set width works'
+);
+
+like(
+    $seg,
+    qr{height="600"},
+    'set height works'
+);
+
+like(
+    $seg,
+    qr{class="foo bar"},
+    'set web_css_class works'
+);
+
+## Pie
+#
+$seg = $renderer->render(
+    type => 'pie',
+    data => $data,
+);
+like ( $seg, qr/"pie"/, "pie type" );



More information about the Bps-public-commit mailing list