Add specs for `ThemeHelper#render_theme`

This commit is contained in:
Andreas Nedbal 2020-05-06 13:48:16 +02:00
parent ec998686ff
commit 4044696a8a
1 changed files with 28 additions and 0 deletions

View File

@ -3,6 +3,34 @@
require "rails_helper" require "rails_helper"
describe ThemeHelper, :type => :helper do describe ThemeHelper, :type => :helper do
describe "#render_theme" do
context "when target page doesn't have a theme" do
it "returns no theme" do
expect(helper.render_theme).to be_nil
end
end
context "when target page has a theme" do
before(:each) do
@user = FactoryBot.create(:user)
@user.theme = Theme.new
@user.save!
end
it "returns a theme" do
expect(helper.render_theme).to include("<style>:root {")
end
it "contains correct theme background colors" do
expect(helper.render_theme).to include("--primary: #5e35b1;")
end
it "properly converts color values for *-text theme attributes" do
expect(helper.render_theme).to include("--primary-text: 255, 255, 255;")
end
end
end
describe "#get_hex_color_from_theme_value" do describe "#get_hex_color_from_theme_value" do
it "returns the proper hex value from the decimal value for white" do it "returns the proper hex value from the decimal value for white" do
expect(helper.get_hex_color_from_theme_value(16777215)).to eq("ffffff") expect(helper.get_hex_color_from_theme_value(16777215)).to eq("ffffff")