Debian Codegraph @

t/fields/repeatable.t

raw
1 use strict;
2 use warnings;
3 use Test::More;
4
5 use_ok('HTML::FormHandler::Field::Repeatable');
6
7 # test to verify that contains hashref passed in to construction of
8 # a repeatable field is used to build the 'contains' field
9 my $args = {
10 name => 'test_field',
11 init_contains => { wrapper_class => ['hfh', 'repinst'] },
12 };
13 my $field = HTML::FormHandler::Field::Repeatable->new( %$args );
14 ok( $field, 'field built' );
15 $field->init_state;
16 is_deeply( $field->contains->wrapper_class, ['hfh', 'repinst'], 'attribute set' );
17
18 {
19 package Test::Form;
20 use HTML::FormHandler::Moose;
21 extends 'HTML::FormHandler';
22
23 has_field 'my_name';
24 has_field 'my_records' => ( type => 'Repeatable', num_when_empty => 2,
25 init_contains => { wrapper_class =>['hfh'] },
26 );
27 has_field 'my_records.one';
28 has_field 'my_records.two';
29 }
30 my $form = Test::Form->new;
31 ok( $form, 'form built' );
32 is_deeply( $form->field('my_records')->contains->wrapper_class, ['hfh'], 'worked in form');
33 my $rendered = $form->render;
34
35
36 done_testing;