#!perl
use Cassandane::Tiny;

sub test_rfc5258_ex03_children
    :UnixHierarchySep :AltNamespace
{
    my ($self) = @_;

    my $imaptalk = $self->{store}->get_client();

    $self->setup_mailbox_structure($imaptalk, [
        [ 'subscribe' => 'INBOX' ],
        [ 'create' => [qw( Fruit Fruit/Apple Fruit/Banana Fruit/Peach)] ],
        [ 'subscribe' => [qw( Fruit/Banana Fruit/Peach )] ],
        [ 'delete' => 'Fruit/Peach' ],
        [ 'create' => [qw( Tofu Vegetable Vegetable/Broccoli Vegetable/Corn )] ],
        [ 'subscribe' => [qw( Vegetable Vegetable/Broccoli )] ],
    ]);

    my $data = $imaptalk->list(
        [qw()], "", "%", 'RETURN', [qw(CHILDREN)],
    );

    $self->assert_mailbox_structure($data, '/', {
        'INBOX' => [ '\\HasNoChildren' ],
        'Fruit' => [ '\\HasChildren' ],
        'Tofu'  => [ '\\HasNoChildren' ],
        'Vegetable' => [ '\\HasChildren' ],
    });
}
