use strict; use warnings; use lib qw( ./lib ../lib ); use Test::More; use Cwd; use CSS::Inliner; plan(tests => 21); # moderately complicated rules with elements and classes my $html = <<'END'; Moderate Document

Lorem ipsum dolor sit amet

Consectetur adipiscing elit

Aliquam ornare luctus egestas.

Nulla vulputate tellus vitae justo luctus scelerisque accumsan nunc porta.

Phasellus pharetra viverra sollicitudin. Vivamus ac enim ante.

Nunc augue massa, dictum id eleifend non posuere nec purus.

Luctus scelerisque accumsan nunc porta

END my $inliner = CSS::Inliner->new(); $inliner->read({html => $html}); my $inlined = $inliner->inlinify(); ok($inlined =~ m/

Lorem ipsum/, 'h1.alert rule inlined'); ok($inlined =~ m/

Consectetur/, 'h1.cool rule inlined'); ok($inlined =~ m/

Aliquam/, '.intro rule inlined'); ok($inlined =~ m/

Phasellus/, 'div p rule inlined'); ok($inlined =~ m/

Nunc augue/, 'div p rule inlined again'); ok($inlined =~ m/

Nulla/, 'no rule for just "p"'); ok($inlined =~ m/

Luctus/, 'rich before the poor'); ok($inlined !~ m/

Lorem ipsum dolor sit amet

Consectetur adipiscing elit

Aliquam ornare luctus egestas.

Nulla vulputate tellus vitae justo luctus scelerisque accumsan nunc porta.

Phasellus pharetra viverra sollicitudin. Vivamus ac enim ante.

Nunc augue massa, dictum id eleifend non posuere nec purus.

Vivamus ac enim ante.

Dictum id eleifend non.

Luctus scelerisque accumsan nunc porta

END $inliner = CSS::Inliner->new(); $inliner->read({html => $html}); $inlined = $inliner->inlinify(); ok($inlined =~ m/

Lorem ipsum/, 'cascading rules for h1.alert.cool inlined'); ok($inlined =~ m/

Consectetur/, 'h1.cool rule inlined'); ok($inlined =~ m/

Aliquam/, '.intro rule inlined'); ok($inlined =~ m/

Nulla/, 'just the "p" rule'); ok($inlined =~ m/

Phasellus/, 'div p rule inlined'); ok($inlined =~ m/

Nunc augue/, 'div p rule inlined again'); ok($inlined =~ m/

Vivamus/, '"div[align=right] p" + "div p" + "p"'); ok($inlined =~ m/

Dictum/, '"div[align=right] p" + "div p" + "p" + "p.rich"'); ok($inlined =~ m/

Luctus/, 'rich before the poor'); ok($inlined !~ m/