Tests for remark form
This commit is contained in:
parent
58fd244198
commit
f8582fbef4
|
@ -24,7 +24,6 @@ Run the tests locally (against development environment)
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Tests for remark form
|
|
||||||
1. Return the last remark with remark form
|
1. Return the last remark with remark form
|
||||||
1. Marked some items for clean up with comments
|
1. Marked some items for clean up with comments
|
||||||
1. Method names may need to be shortened
|
1. Method names may need to be shortened
|
||||||
|
|
33
t/post.t
33
t/post.t
|
@ -6,40 +6,53 @@ use Test::More;
|
||||||
use Mojo::File qw{curfile};
|
use Mojo::File qw{curfile};
|
||||||
use Test::Mojo;
|
use Test::Mojo;
|
||||||
|
|
||||||
my $script = curfile->dirname->sibling('PostText.pl');
|
my $script = curfile->dirname->sibling('PostText.pl');
|
||||||
my $t = Test::Mojo->new($script);
|
my $t = Test::Mojo->new($script);
|
||||||
my %valid_params = (
|
my %valid_params = (
|
||||||
name => 'Anonymous',
|
name => 'Anonymous',
|
||||||
title => 'hi',
|
title => 'hi',
|
||||||
post => 'ayy... lmao'
|
post => 'ayy... lmao'
|
||||||
);
|
);
|
||||||
my %invalid_title = (
|
my %invalid_title = (
|
||||||
name => 'Anonymous',
|
name => 'Anonymous',
|
||||||
title => '',
|
title => '',
|
||||||
post => 'ayy... lmao'
|
post => 'ayy... lmao'
|
||||||
);
|
);
|
||||||
my %invalid_post = (
|
my %invalid_post = (
|
||||||
name => 'Anonymous',
|
name => 'Anonymous',
|
||||||
title => 'hi',
|
title => 'hi',
|
||||||
post => 'a'
|
post => 'a'
|
||||||
);
|
);
|
||||||
|
my %valid_remark = (
|
||||||
|
name => 'Anonymous',
|
||||||
|
post => 'hi'
|
||||||
|
);
|
||||||
|
my %invalid_remark = (
|
||||||
|
name => 'Anonymous',
|
||||||
|
post => 'a'
|
||||||
|
);
|
||||||
|
|
||||||
$t->ua->max_redirects(1);
|
$t->ua->max_redirects(1);
|
||||||
|
|
||||||
# GET
|
# GET
|
||||||
$t->get_ok('/post')->status_is(200)->text_like(h2 => qr/New Thread/);
|
$t->get_ok('/post' )->status_is(200)->text_like(h2 => qr/New Thread/);
|
||||||
|
$t->get_ok('/post/1')->status_is(200)->text_like(h2 => qr/New Remark/);
|
||||||
|
|
||||||
# POST
|
# POST
|
||||||
$t->post_ok('/post')->status_is(200)->text_like(h2 => qr/New Thread/);
|
$t->post_ok('/post' )->status_is(200)->text_like(h2 => qr/New Thread/);
|
||||||
|
|
||||||
$t->post_ok('/post', form => \%invalid_title)->status_is(400)
|
$t->post_ok('/post', form => \%invalid_title)->status_is(400)
|
||||||
->text_like(p => qr/Invalid title/);
|
->text_like(p => qr/Invalid title/);
|
||||||
|
|
||||||
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
|
$t->post_ok('/post', form => \%invalid_post)->status_is(400)
|
||||||
->text_like(p => qr/Invalid post/);
|
->text_like(p => qr/Invalid post/);
|
||||||
|
|
||||||
$t->post_ok('/post', form => \%valid_params)->status_is(200)
|
$t->post_ok('/post', form => \%valid_params)->status_is(200)
|
||||||
->text_like(h2 => qr/Threads List/);
|
->text_like(h2 => qr/Threads List/);
|
||||||
|
|
||||||
|
$t->post_ok('/post/1')->status_is(200)->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(h2 => qr/New Remark/);
|
||||||
|
|
||||||
done_testing();
|
done_testing();
|
||||||
|
|
Loading…
Reference in a new issue