#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 6;
use HTML::FormFu;
use Regexp::Common;


sub test_group_option_attr_escaping {
    my ($elem_type) = @_;

    my $form = new HTML::FormFu;
    my $field = $form->element($elem_type)->name('test')
	->options([
	    { value => 1,
	      label => 'First',
	      attributes => { myattr => 'needs&escaping' },
	      label_attributes => { myattr => 'needs&escaping' },
	      container_attributes => { myattr => 'needs&escaping' },},
	    { value => 2,
	      label => 'Second',
	      attributes_xml => { myattr => 'pre&amp;escaped' } },
	]);


    unlike $field, qr/myattr=.needs&escaping/,
	"$elem_type: option attributes";

    like $field, qr/myattr=.pre&amp;escaped/,
	"$elem_type: option attributes_xml";
}

test_group_option_attr_escaping($_)
    for qw/Select Radiogroup Checkboxgroup/;


