File: riotjs.t

package info (click to toggle)
libmojolicious-plugin-assetpack-perl 2.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,888 kB
  • sloc: perl: 1,503; javascript: 52; makefile: 8; sh: 2
file content (38 lines) | stat: -rw-r--r-- 1,173 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use lib '.';
use t::Helper;

plan skip_all => 'cpanm JavaScript::Minifier::XS' unless eval 'require JavaScript::Minifier::XS;1';
plan skip_all => 'TEST_RIOTJS=1'                  unless $ENV{TEST_RIOTJS} or -e '.test-everything';

my $t = t::Helper->t(pipes => [qw(Riotjs JavaScript)]);
$t->app->asset->process('app.js' => ('r1.tag'));
$t->get_ok('/')->status_is(200)->element_exists(qq(script[src="/asset/7373328564/r1.js"]));

$t->get_ok($t->tx->res->dom->at('script')->{src})->status_is(200)
  ->content_like(qr{^\s*riot\.tag.*onclick=.*"foo";\n\s+this\.clicked.*\);\s*}s);

$ENV{MOJO_MODE} = 'Test_minify_from_here';
$t = t::Helper->t(pipes => [qw(Riotjs JavaScript)]);
$t->app->asset->process('app.js' => ('r1.tag'));
$t->get_ok('/')->status_is(200)->element_exists(qq(script[src="/asset/7373328564/r1.js"]));

$t->get_ok($t->tx->res->dom->at('script')->{src})->status_is(200)->content_like(qr{"foo";this\.clicked});

done_testing;

__DATA__
@@ index.html.ep
%= asset 'app.js'
@@ r1.tag
<custom-tag>
  <div>
    <button onclick={clicked}>{text}</button>
  </div>
  <script>
  this.text = "foo";

  clicked(e) {
    console.log(e.target);
  }
  </script>
</custom-tag>