Skip to content

Commit

Permalink
Added Test::Mojo::content_* tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rage311 committed Oct 30, 2020
1 parent 6a8a39d commit a68cb47
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions t/test/mojo.t
Original file line number Diff line number Diff line change
Expand Up @@ -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('<p id="test">Test</p>');
$t->attr_is('p', 'id', 'wrong');
Expand Down

0 comments on commit a68cb47

Please sign in to comment.