require "rails_helper"

RSpec.describe Scoring::ApplyAction do
  let!(:user) { User.create!(email: "score@test.it", name: "U", password: "password123", role: "coach") }
  let!(:club) { Club.create!(name: "C", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff") }
  let!(:team) { club.teams.create!(name: "T", sport: "volleyball") }
  let!(:match) { team.matches.create!(opponent_name: "Opp", sport: "volleyball", sets_to_win: 3) }
  let!(:session) { StreamSession.create!(match: match, user: user, platform: "matchlivetv", status: "live") }

  it "incrementa i punti casa" do
    session.create_score_state!(home_sets: 0, away_sets: 0, home_points: 0, away_points: 0, current_set: 1)
    result = described_class.new(session: session, action: "home_point").call
    expect(result.score.home_points).to eq(1)
  end
end
