File Coverage

blib/lib/Test/Web/AssetLib/TestLibrary.pm
Criterion Covered Total %
statement 33 33 100.0
branch n/a
condition n/a
subroutine 15 15 100.0
pod 0 6 0.0
total 48 54 88.8


line stmt bran cond sub pod time code
1             package Test::Web::AssetLib::TestLibrary;
2              
3 5     5   14237863 use Method::Signatures;
  5         51953  
  5         43  
4 5     5   2487 use Moose;
  5         291015  
  5         31  
5 5     5   22689 use FindBin qw($Bin);
  5         896  
  5         618  
6              
7 5     5   2058 use Web::AssetLib::InputEngine::LocalFile;
  5         12  
  5         154  
8 5     5   2384 use Web::AssetLib::InputEngine::RemoteFile;
  5         16  
  5         153  
9 5     5   2858 use Web::AssetLib::InputEngine::Content;
  5         22  
  5         152  
10              
11 5     5   2141 use Web::AssetLib::MinifierEngine::Standard;
  5         19  
  5         173  
12              
13 5     5   2580 use Web::AssetLib::OutputEngine::LocalFile;
  5         15  
  5         184  
14 5     5   2323 use Web::AssetLib::OutputEngine::String;
  5         14  
  5         1336  
15              
16             extends 'Web::AssetLib::Library';
17              
18             has '+input_engines' => (
19             default => sub {
20             [ Web::AssetLib::InputEngine::LocalFile->new(
21             search_paths => ["$Bin/assets/"]
22             ),
23             Web::AssetLib::InputEngine::RemoteFile->new(),
24             Web::AssetLib::InputEngine::Content->new()
25             ];
26             }
27             );
28              
29             has '+minifier_engines' => (
30             default => sub {
31             [ Web::AssetLib::MinifierEngine::Standard->new() ];
32             }
33             );
34              
35             has '+output_engines' => (
36             default => sub {
37             [ Web::AssetLib::OutputEngine::LocalFile->new(
38             output_path => "$Bin/output/",
39             link_path => '/static/'
40             ),
41             Web::AssetLib::OutputEngine::String->new()
42             ];
43             }
44             );
45              
46             sub testjs_local {
47 2     2 0 1948 return Web::AssetLib::Asset->new(
48             name => 'testjs_local',
49             type => 'javascript',
50             input_engine => 'LocalFile',
51             input_args => { path => 'test.js', }
52             );
53             }
54              
55             sub testcss_local {
56 3     3 0 34 return Web::AssetLib::Asset->new(
57             name => 'testcss_local',
58             type => 'css',
59             input_engine => 'LocalFile',
60             input_args => { path => 'test.css', }
61             );
62             }
63              
64             sub testjs_remote {
65 3     3 0 1587 return Web::AssetLib::Asset->new(
66             name => 'testjs_remote',
67             type => 'javascript',
68             input_engine => 'RemoteFile',
69             input_args => {
70             url =>
71             'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js',
72             }
73             );
74             }
75              
76             sub testcss_remote {
77 4     4 0 54 return Web::AssetLib::Asset->new(
78             name => 'testcss_remote',
79             type => 'css',
80             input_engine => 'RemoteFile',
81             input_args => {
82             url =>
83             'https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css',
84             }
85             );
86             }
87              
88             sub missingjs_remote {
89 1     1 0 423 return Web::AssetLib::Asset->new(
90             name => 'missingjs_remote',
91             type => 'javascript',
92             input_engine => 'RemoteFile',
93             input_args => { url => 'https://foo/bar', }
94             );
95             }
96              
97             sub testjs_async_passthru {
98 1     1 0 14 return Web::AssetLib::Asset->new(
99             name => 'testjs_remote',
100             type => 'javascript',
101             input_engine => 'RemoteFile',
102             isPassthru => 1,
103             default_html_attrs => { async => 'async' },
104             input_args => {
105             url =>
106             'https://ajax.googleapis.com/ajax/libs/jquery/4.1.0/jquery.min.js',
107             }
108             );
109             }
110              
111             1;