[Bps-public-commit] r11965 - in HTML-RewriteAttributes: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Apr 29 18:54:25 EDT 2008


Author: sartak
Date: Tue Apr 29 18:54:20 2008
New Revision: 11965

Added:
   HTML-RewriteAttributes/t/021-import.t
Modified:
   HTML-RewriteAttributes/   (props changed)

Log:
 r54671 at onn:  sartak | 2008-04-29 18:32:31 -0400
 Tests for @import


Added: HTML-RewriteAttributes/t/021-import.t
==============================================================================
--- (empty file)
+++ HTML-RewriteAttributes/t/021-import.t	Tue Apr 29 18:54:20 2008
@@ -0,0 +1,69 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use HTML::RewriteAttributes::Resources;
+use Test::More tests => 4;
+
+my $html = << 'END';
+<html>
+    <head>
+        <link type="text/css" href="foo.css" />
+        <style type="text/css">
+ at import "bar.css";
+        </style>
+        <link type="text/css" href="baz.css" />
+    </head>
+    <body>
+    </body>
+</html>
+END
+
+my %css = (
+    "foo.css"  => 'foo; @import "quux.css";',
+    "bar.css"  => 'bar; @import "quux.css";',
+    "baz.css"  => 'baz; @import "foo.css";',
+    "quux.css" => 'quux; @import "bar.css"; @import "quux.css";',
+);
+
+my @seen;
+my @seen_css;
+
+my $rewrote = HTML::RewriteAttributes::Resources->rewrite($html, sub {
+    my $uri = shift;
+    push @seen, $uri;
+    return $uri;
+}, inline_css => sub {
+    my $uri = shift;
+    push @seen_css, $uri;
+    return $css{$uri};
+}, inline_imports => 1);
+
+
+$rewrote =~ s/ +$//mg;
+$rewrote =~ s/^ +//mg;
+
+is($rewrote, << 'END', "rewrote the html correctly");
+<html>
+<head>
+
+<style type="text/css">
+<!--
+foo; quux; bar;
+-->
+</style>
+
+<style type="text/css">
+
+</style>
+
+<style type="text/css">
+<!--
+baz; foo;
+-->
+</style>
+
+</head>
+<body>
+</body>
+</html>
+END



More information about the Bps-public-commit mailing list