discourse/spec/components/email/email_styles_spec.rb

41 lines
942 B
Ruby
Raw Normal View History

require 'spec_helper'
require 'email'
2013-06-10 15:33:37 -04:00
describe Email::Styles do
def style_exists(html, css_rule)
2013-06-10 15:33:37 -04:00
fragment = Nokogiri::HTML.fragment(Email::Styles.new(html).format)
element = fragment.at(css_rule)
expect(element["style"]).not_to be_blank
end
it "returns blank from an empty string" do
2013-06-10 15:33:37 -04:00
Email::Styles.new("").format.should be_blank
end
it "attaches a style to h3 tags" do
style_exists("<h3>hello</h3>", "h3")
end
it "attaches a style to hr tags" do
style_exists("hello<hr>", "hr")
end
it "attaches a style to a tags" do
style_exists("<a href='#'>wat</a>", "a")
end
it "attaches a style to ul tags" do
style_exists("<ul><li>hello</li></ul>", "ul")
end
it "attaches a style to li tags" do
style_exists("<ul><li>hello</li></ul>", "li")
end
it "removes pre tags but keeps their contents" do
2013-06-10 15:33:37 -04:00
expect(Email::Styles.new("<pre>hello</pre>").format).to eq("hello")
end
end