Akron | cb5c171 | 2021-01-26 18:01:04 +0100 | [diff] [blame^] | 1 | use Mojolicious; |
| 2 | use Test::Mojo; |
| 3 | use Test::More; |
| 4 | |
| 5 | my $app = Mojolicious->new; |
| 6 | my $t = Test::Mojo->new($app); |
| 7 | |
| 8 | # Client notifications |
| 9 | $app->plugin(Notifications => { |
| 10 | 'Kalamar::Plugin::Notifications' => 1, |
| 11 | JSON => 1, |
| 12 | HTML => 1 |
| 13 | }); |
| 14 | |
| 15 | my $c = $app->build_controller; |
| 16 | |
| 17 | is($c->notifications('Kalamar::Plugin::Notifications'), ''); |
| 18 | |
| 19 | $c->notify(warn => 'Error'); |
| 20 | $c->notify('warn' => 20, 'Hmmm'); |
| 21 | $c->notify('success' => {src => 'Kustvakt'}, 'Hmmm'); |
| 22 | |
| 23 | my $n = $c->notifications('Kalamar::Plugin::Notifications'); |
| 24 | |
| 25 | like($n, qr!^<div id="notifications">.*</div>$!s); |
| 26 | like($n, qr!<div class="notify notify-warn" data-type="warn">Error</div>!); |
| 27 | like($n, qr!<div class="notify notify-warn" data-type="warn">Hmmm</div>!); |
| 28 | like($n, qr!<div class="notify notify-success" data-type="success" data-src="Kustvakt">Hmmm</div>!); |
| 29 | |
| 30 | done_testing; |
| 31 | __END__ |