require "rails_helper"

RSpec.describe Authentication::Providers::Github, type: :service do
  describe ".authentication_path" do
    it "returns the correct authentication path" do
      expected_path = Rails.application.routes.url_helpers.user_github_omniauth_authorize_path
      expect(described_class.authentication_path).to eq(expected_path)
    end

    it "supports additional parameters" do
      path = described_class.authentication_path(state: "state")
      expect(path).to include("state=state")
    end
  end

  describe ".sign_in_path" do
    let(:expected_path) do
      "/users/auth/github?callback_url=http%3A%2F%2Flocalhost%3A3000%2Fusers%2Fauth%2Fgithub%2Fcallback"
    end

    it "returns the correct sign in path" do
      expect(described_class.sign_in_path).to eq(expected_path)
    end

    it "supports additional parameters" do
      path = described_class.sign_in_path(state: "state")
      expect(path).to include("state=state")
    end

    it "does not override the callback_url parameter" do
      path = described_class.sign_in_path(callback_url: "https://example.com/callback")
      expect(path).to eq(expected_path)
    end
  end
end
