PostText/t/post.t

37 lines
816 B
Perl
Raw Normal View History

#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Mojo::File qw{curfile};
use Test::Mojo;
2022-08-15 17:11:14 -04:00
my $script = curfile->dirname->sibling('PostText.pl');
my $t = Test::Mojo->new($script);
my %valid_params = (
2022-08-14 00:30:26 -04:00
name => 'Anonymous',
title => 'hi',
post => 'ayy... lmao'
2022-08-14 00:30:26 -04:00
);
2022-08-15 17:11:14 -04:00
my %invalid_params = (
name => 'Anonymous',
title => '',
post => 'a'
);
2022-08-14 00:30:26 -04:00
$t->ua->max_redirects(1);
2022-08-15 17:11:14 -04:00
# GET
$t->get_ok('/post')->status_is(200)->text_like(h2 => qr/New Thread/);
# POST
$t->post_ok('/post')->status_is(200)->text_like(h2 => qr/New Thread/);
2022-08-14 00:30:26 -04:00
2022-08-15 17:11:14 -04:00
$t->post_ok('/post', form => \%invalid_params)->status_is(400)
->text_like(h2 => qr/View Threads/);
2022-08-14 00:30:26 -04:00
$t->post_ok('/post', form => \%valid_params)->status_is(200)
->text_like(h2 => qr/View Threads/);
done_testing();