File: repeatable.t

package info (click to toggle)
libhtml-formhandler-perl 0.40057-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,320 kB
  • ctags: 685
  • sloc: perl: 8,849; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use Test::More;

use_ok('HTML::FormHandler::Field::Repeatable');

# test to verify that contains hashref passed in to construction of
# a repeatable field is used to build the 'contains' field
my $args = {
   name => 'test_field',
   init_contains => { wrapper_class => ['hfh', 'repinst'] },
};
my $field = HTML::FormHandler::Field::Repeatable->new( %$args );
ok( $field, 'field built' );
$field->init_state;
is_deeply( $field->contains->wrapper_class, ['hfh', 'repinst'], 'attribute set' );

{
    package Test::Form;
    use HTML::FormHandler::Moose;
    extends 'HTML::FormHandler';

    has_field 'my_name';
    has_field 'my_records' => ( type => 'Repeatable', num_when_empty => 2,
        init_contains => { wrapper_class =>['hfh'] },
    );
    has_field 'my_records.one';
    has_field 'my_records.two';
}
my $form = Test::Form->new;
ok( $form, 'form built' );
is_deeply( $form->field('my_records')->contains->wrapper_class, ['hfh'], 'worked in form');
my $rendered = $form->render;


done_testing;