diff --git a/t/test/mojo.t b/t/test/mojo.t index 0551182059..a79bce4f45 100644 --- a/t/test/mojo.t +++ b/t/test/mojo.t @@ -83,6 +83,60 @@ subtest 'content_is' => sub { is_deeply \@args, ['is', 'Hello Test!', 'Hello Test!', 'some description'], 'right result'; }; +subtest 'content_isnt' => sub { + $t->content_isnt('Goodbye Test!'); + is_deeply \@args, ['isnt', 'Hello Test!', 'Goodbye Test!', 'no match for content'], 'right result'; + $t->content_isnt('Goodbye Test!', 'some description'); + is_deeply \@args, ['isnt', 'Hello Test!', 'Goodbye Test!', 'some description'], 'right result'; +}; + +subtest 'content_like' => sub { + $t->content_like(qr/Hello Test!/); + is_deeply \@args, ['like', 'Hello Test!', qr/Hello Test!/, 'content is similar'], 'right result'; + $t->content_like(qr/Hello Test!/, 'some description'); + is_deeply \@args, ['like', 'Hello Test!', qr/Hello Test!/, 'some description'], 'right result'; +}; + +subtest 'content_type_is' => sub { + $t->content_type_is('text/html;charset=UTF-8'); + is_deeply \@args, + ['is', 'text/html;charset=UTF-8', 'text/html;charset=UTF-8', 'Content-Type: text/html;charset=UTF-8'], + 'right result'; + $t->content_type_is('text/html;charset=UTF-8', 'some description'); + is_deeply \@args, ['is', 'text/html;charset=UTF-8', 'text/html;charset=UTF-8', 'some description'], 'right result'; +}; + +subtest 'content_type_isnt' => sub { + $t->content_type_isnt('image/png'); + is_deeply \@args, ['isnt', 'text/html;charset=UTF-8', 'image/png', 'not Content-Type: image/png'], 'right result'; + $t->content_type_isnt('image/png', 'some description'); + is_deeply \@args, ['isnt', 'text/html;charset=UTF-8', 'image/png', 'some description'], 'right result'; +}; + +subtest 'content_type_like' => sub { + $t->content_type_like(qr/text\/html;charset=UTF-8/); + is_deeply \@args, ['like', 'text/html;charset=UTF-8', qr/text\/html;charset=UTF-8/, 'Content-Type is similar'], + 'right result'; + $t->content_type_like(qr/text\/html;charset=UTF-8/, 'some description'); + is_deeply \@args, ['like', 'text/html;charset=UTF-8', qr/text\/html;charset=UTF-8/, 'some description'], + 'right result'; +}; + +subtest 'content_type_unlike' => sub { + $t->content_type_unlike(qr/image\/png/); + is_deeply \@args, ['unlike', 'text/html;charset=UTF-8', qr/image\/png/, 'Content-Type is not similar'], + 'right result'; + $t->content_type_unlike(qr/image\/png/, 'some description'); + is_deeply \@args, ['unlike', 'text/html;charset=UTF-8', qr/image\/png/, 'some description'], 'right result'; +}; + +subtest 'content_unlike' => sub { + $t->content_unlike(qr/Goodbye Test!/); + is_deeply \@args, ['unlike', 'Hello Test!', qr/Goodbye Test!/, 'content is not similar'], 'right result'; + $t->content_unlike(qr/Goodbye Test!/, 'some description'); + is_deeply \@args, ['unlike', 'Hello Test!', qr/Goodbye Test!/, 'some description'], 'right result'; +}; + subtest 'attr_is' => sub { $t->tx->res->body('
Test
'); $t->attr_is('p', 'id', 'wrong');