Akron | f7ec444 | 2019-10-27 20:01:05 +0100 | [diff] [blame] | 1 | package Kalamar::Plugin::Test; |
| 2 | use Mojo::Base 'Mojolicious::Plugin'; |
| 3 | |
| 4 | |
| 5 | sub register { |
| 6 | my ($plugin, $app, $param) = @_; |
| 7 | |
| 8 | # Add entry to settings navigation |
| 9 | $app->navi->add(settings => ( |
| 10 | 'OAuth Token Management', 'oauth' |
| 11 | )); |
| 12 | |
| 13 | $app->routes->get('/settings/oauth')->to( |
| 14 | cb => sub { |
| 15 | my $c = shift; |
| 16 | $c->content_with(settings => '<p id="abc">My Settings</p>'); |
| 17 | return $c->render('settings'); |
| 18 | } |
| 19 | ); |
| 20 | }; |
| 21 | |
| 22 | package main; |
| 23 | use Mojo::Base -strict; |
| 24 | use Test::More; |
| 25 | use Test::Mojo; |
| 26 | use Mojo::ByteStream 'b'; |
| 27 | |
| 28 | my $t = Test::Mojo->new('Kalamar' => { |
| 29 | Kalamar => { |
| 30 | plugins => ['Test'] |
| 31 | } |
| 32 | }); |
| 33 | |
Akron | f7ec444 | 2019-10-27 20:01:05 +0100 | [diff] [blame] | 34 | $t->get_ok('/settings') |
Akron | 8f9aae5 | 2020-12-17 15:52:28 +0100 | [diff] [blame] | 35 | ->text_is('a[href*=/settings/oauth]','OAuth Token Management') |
Akron | 5999212 | 2019-10-29 11:28:45 +0100 | [diff] [blame] | 36 | ->text_is('h1 span', 'Settings') |
Akron | f7ec444 | 2019-10-27 20:01:05 +0100 | [diff] [blame] | 37 | ; |
| 38 | |
| 39 | $t->get_ok('/settings/oauth') |
Akron | 8f9aae5 | 2020-12-17 15:52:28 +0100 | [diff] [blame] | 40 | ->text_is('a[href*=/settings/oauth]','OAuth Token Management') |
Akron | 5999212 | 2019-10-29 11:28:45 +0100 | [diff] [blame] | 41 | ->text_is('h1 span', 'Settings') |
| 42 | ->text_is('p#abc', 'My Settings') |
Akron | f7ec444 | 2019-10-27 20:01:05 +0100 | [diff] [blame] | 43 | ; |
| 44 | |
| 45 | done_testing; |
| 46 | __END__ |