PostText/t/remark.t

44 lines
1.2 KiB
Perl
Raw Normal View History

2022-10-01 18:00:23 -04:00
use Mojo::Base -strict;
2022-09-03 13:08:03 -04:00
use Test::More;
use Test::Mojo;
2022-10-01 18:00:23 -04:00
my $t = Test::Mojo->new('PostText');
2022-09-03 13:08:03 -04:00
2022-10-05 22:46:15 -04:00
my %valid_remark = (
author => 'Anonymous',
body => 'hi'
);
my %invalid_remark = (
author => 'Anonymous',
body => 'a'
);
subtest 'View single remark', sub {
$t->get_ok('/remark/1')->status_is(200)->text_like(h2 => qr/Remark #1/);
};
$t->ua->max_redirects(1);
subtest 'Post new remark', sub {
2022-10-05 22:46:15 -04:00
# GET
$t->get_ok('/post/1')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Remark/);
# POST
$t->post_ok('/post/1')->status_is(200)
->element_exists('form input[name="author"]' )
->element_exists('form textarea[name="body"]')
->element_exists('form input[type="submit"]' )
->text_like(h2 => qr/New Remark/);
$t->post_ok('/post/1', form => \%valid_remark)->status_is(200)
->text_like(h2 => qr/Thread #1/);
$t->post_ok('/post/1', form => \%invalid_remark)->status_is(400)
->text_like(p => qr/Invalid text/);
};
2022-09-03 13:08:03 -04:00
done_testing();