Retrospring/spec/components/avatar_component_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
958 B
Ruby
Raw Normal View History

2023-10-20 02:46:43 -07:00
# frozen_string_literal: true
require "rails_helper"
RSpec.describe AvatarComponent, type: :component do
let(:user) { FactoryBot.create(:user) }
it "renders an avatar" do
expect(
render_inline(described_class.new(user:, size: "sm")).to_html,
).to include(
"no_avatar.png",
)
end
it "gets the medium version of a profile picture if requested" do
expect(
render_inline(described_class.new(user:, size: "md")).to_html,
).to include(
"medium/",
)
end
it "gets the large version of a profile picture if requested" do
expect(
render_inline(described_class.new(user:, size: "xl")).to_html,
).to include(
"large/",
)
end
it "includes additionally passed classes" do
expect(
render_inline(described_class.new(user:, size: "md", classes: %w[first-class second-class])).to_html,
).to include(
'class="avatar-md first-class second-class"',
)
end
end