Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds view-level unit specs for `Marketplace::Cart::DeliveryAreaComponent' #1926

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<%= delivery_area.label %>
<div class="text-sm text-gray-500">
<%= render(Marketplace::Cart::DeliveryExpectationsComponent.new(cart: cart)) %>
<%- if single_delivery_area? %>
<div><small>Orders outside of this location will be subject to cancellation.</small></div>
<% end %>
Comment on lines +9 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing finds (UX) bugs. 💪 Although could use a little design love:

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, it looks good enough for now :)

</div>
</div>
<div class="text-right">
Expand Down
35 changes: 35 additions & 0 deletions spec/furniture/marketplace/cart/delivery_area_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require "rails_helper"

RSpec.describe Marketplace::Cart::DeliveryAreaComponent, type: :component do
subject(:output) { render_inline(component) }

let(:component) { described_class.new(cart: cart) }

let(:cart) { create(:marketplace_cart, marketplace: marketplace) }

context "when a delivery area is present" do
context "with a single delivery area" do
let(:marketplace) { create(:marketplace, :with_delivery_areas) }

it { is_expected.to have_content "Orders outside of this location will be subject to cancellation." }
end

context "with multiple delivery areas" do
let(:marketplace) {
create(:marketplace, :with_delivery_areas, delivery_area_quantity: 2)
}

it { is_expected.to have_content "Where are you Ordering from?" }
it { is_expected.to have_content "Delivery prices and times vary based upon your location" }
it { is_expected.to have_css("option", count: 2) }
end
end

context "when a delivery area is not present" do
let(:marketplace) { create(:marketplace) }

it { is_expected.to have_content("Where are you Ordering from?") }
it { is_expected.to have_content "Delivery prices and times vary based upon your location" }
it { is_expected.not_to have_css("option") }
end
end