#!perl
use Cassandane::Tiny;

sub test_email_get_bodyvalues_crlf
    :min_version_3_9
{
    my ($self) = @_;
    my $jmap = $self->{jmap};
    my $imap = $self->{store}->get_client();

    my $mimeMsg = <<'EOF';
From: <from@local>
To: to@local
Bcc: bcc@local
Subject: test
Date: Mon, 13 Apr 2020 15:34:03 +0200
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;charset=utf-8

one
two
three
EOF
    $mimeMsg =~ s/\r?\n/\r\n/gs;
    $mimeMsg =~ s/\r\n$//;
    $imap->append('INBOX', $mimeMsg) || die $@;

    my $res = $jmap->CallMethods([
        ['Email/query', { }, 'R1'],
        ['Email/get', {
            '#ids' => {
                resultOf => 'R1',
                name => 'Email/query',
                path => '/ids'
            },
            properties => ['bodyValues'],
            fetchAllBodyValues => JSON::true,
        }, 'R2'],
    ]);

    $self->assert_str_equals("one\ntwo\nthree",
        $res->[1][1]{list}[0]{bodyValues}{1}{value});
}
