File: 01-interface.t

package info (click to toggle)
libcss-packer-perl 1.002001-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 268 kB
  • ctags: 150
  • sloc: perl: 2,399; makefile: 2
file content (62 lines) | stat: -rw-r--r-- 2,140 bytes parent folder | download | duplicates (3)
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 CSS::Packer; };

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

    plan tests => $not;

    my $packer = CSS::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(), 'pretty', '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( 'minify' );
    is( $packer->compress(), 'minify', 'Set compress to "minify".' );
    $packer->compress( 'foo' );
    is( $packer->compress(), 'minify', 'Set compress to "foo" failed.' );
    $packer->compress( 'pretty' );
    is( $packer->compress(), 'pretty', 'Setting compress back to "pretty".' );

    $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(), 'pretty', 'Default value for compress is still set.' );

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

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