require "rails_helper"

RSpec.describe Api::EventsController, type: :request do
  describe "GET /api/events" do
    it "returns upcoming events" do
      create(:event, name: "Future Jam", date: 1.week.from_now)
      create(:event, name: "Past Jam", date: 1.week.ago)

      get "/api/events"

      expect(response).to have_http_status(:ok)
      json = JSON.parse(response.body)
      names = json.map { |e| e["name"] }
      expect(names).to include("Future Jam")
      expect(names).not_to include("Past Jam")
    end
  end
end
