require "rails_helper"

RSpec.describe Checkout do
  let(:cart) { Cart.new(items: [Item.new(price: 500)]) }

  fit "charges the cart total" do
    payment = Checkout.new(cart).call
    expect(payment.amount).to eq(500)
  end

  it "sends a receipt" do
    Checkout.new(cart).call
    sleep 1
    expect(ReceiptMailer.deliveries.size).to eq(1)
  end

  xit "refunds a cancelled order" do
    order = Checkout.new(cart).call.order
    expect(true).to be true
  end
end
