File: 01-interface.t

package info (click to toggle)
libjavascript-packer-perl 2.12%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,280 kB
  • sloc: javascript: 16,839; perl: 868; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 2,161 bytes parent folder | download | duplicates (7)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!perl -T

use Test::More;

my $not = 18;

SKIP: {
    eval { use JavaScript::Packer; };

    skip( 'JavaScript::Packer not installed!', $not ) if ( $@ );

    plan tests => $not;

    my $packer = JavaScript::Packer->init();

    ok( !$packer->no_compress_comment(), 'Default value for no_compress_comment' );
    ok( !$packer->remove_copyright(),    'Default value for remove_copyright' );
    is( $packer->compress(),  'clean', 'Default value for compress' );
    is( $packer->copyright(), '',      'Default value for copyright' );

    $packer->no_compress_comment( 1 );
    ok( $packer->no_compress_comment(), 'Set no_compress_comment.' );
    $packer->no_compress_comment( 0 );
    ok( !$packer->no_compress_comment(), 'Unset no_compress_comment.' );

    $packer->remove_copyright( 1 );
    ok( $packer->remove_copyright(), 'Set remove_copyright.' );
    $packer->remove_copyright( 0 );
    ok( !$packer->remove_copyright(), 'Unset remove_copyright.' );

    $packer->compress( 'shrink' );
    is( $packer->compress(), 'shrink', 'Set compress to "shrink".' );
    $packer->compress( 'foo' );
    is( $packer->compress(), 'shrink', 'Set compress to "foo" failed.' );
    $packer->compress( 'clean' );
    is( $packer->compress(), 'clean', 'Setting compress back to "clean".' );

    $packer->copyright( 'Ich war\'s!' );
    is( $packer->copyright(), "/* Ich war's! */\n", 'Set copyright' );
    $packer->copyright( 'Ich war\'s' . "\n" . 'nochmal!' );
    is( $packer->copyright(), "/* Ich war's\nnochmal! */\n", 'Set copyright' );
    $packer->copyright( '' );
    is( $packer->copyright(), '', 'Reset copyright' );

    my $str = '';

    $packer->minify( \$str, {} );

    ok( !$packer->no_compress_comment(), 'Default value for no_compress_comment is still set.' );
    is( $packer->compress(), 'clean', 'Default value for compress is still set.' );

    $packer->minify(
        \$str,
        {
            compress            => 'shrink',
            no_compress_comment => 1,
        }
    );

    ok( $packer->no_compress_comment(), 'Set no_compress_comment again.' );
    is( $packer->compress(), 'shrink', 'Set compress to "minify" again.' );
}