Changeset 532

Show
Ignore:
Timestamp:
04/18/12 11:27:21 (14 months ago)
Author:
kake
Message:

Added some basic function tests for the JSON plugin (fixes #40).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit-plugin-json/trunk/t/002_basic_invocation.t

    r530 r532  
    11use strict; 
     2use JSON; 
    23use Test::More; 
    34use Wiki::Toolkit::Plugin::JSON; 
     
    78    plan skip_all => "no backends configured"; 
    89} else { 
    9     plan tests => ( 1 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
     10    plan tests => ( 3 * scalar @Wiki::Toolkit::TestLib::wiki_info ); 
    1011} 
    1112  
     
    4041    ); 
    4142 
    42     my $output; 
    43     eval { 
     43    my $output = eval { 
    4444           local $SIG{__WARN__} = sub { die $_[0]; }; 
    45             $output = $json->recent_changes; 
     45            $json->recent_changes; 
    4646    }; 
    4747    ok( !$@, "->recent_changes() doesn't warn." ); 
     48 
     49    my $parsed = eval { 
     50           local $SIG{__WARN__} = sub { die $_[0]; }; 
     51           decode_json( $output ); 
     52    }; 
     53    ok( !$@, "...and its output looks like JSON." ); 
     54    is( scalar @$parsed, 3, "...and has the right number of nodes." ); 
    4855} 
    4956