blob: 9eb06553b5c92c6a283767249affe2e75594f0f5 [file] [log] [blame]
Akronf7ec4442019-10-27 20:01:05 +01001package Kalamar::Plugin::Test;
2use Mojo::Base 'Mojolicious::Plugin';
3
4
5sub 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
22package main;
23use Mojo::Base -strict;
24use Test::More;
25use Test::Mojo;
26use Mojo::ByteStream 'b';
27
28my $t = Test::Mojo->new('Kalamar' => {
29 Kalamar => {
30 plugins => ['Test']
31 }
32});
33
Akronf7ec4442019-10-27 20:01:05 +010034$t->get_ok('/settings')
35 ->text_is('a[href~/settings/oauth]','OAuth Token Management')
Akron59992122019-10-29 11:28:45 +010036 ->text_is('h1 span', 'Settings')
Akronf7ec4442019-10-27 20:01:05 +010037 ;
38
39$t->get_ok('/settings/oauth')
40 ->text_is('a[href~/settings/oauth]','OAuth Token Management')
Akron59992122019-10-29 11:28:45 +010041 ->text_is('h1 span', 'Settings')
42 ->text_is('p#abc', 'My Settings')
Akronf7ec4442019-10-27 20:01:05 +010043 ;
44
45done_testing;
46__END__