# typed: false
# frozen_string_literal: true

require "rails_helper"

describe Domain::Sofurry::PostPageParser do
  it "detects logged in" do
    parser = get_parser("view_post/2219564.logged_in.html")
    expect(parser.logged_in?).to eq(true)
  end

  it "detects not logged in" do
    parser = get_parser("view_post/2219564.not_logged_in.html")
    expect(parser.logged_in?).to eq(false)
  end

  it "detects post not found" do
    parser = get_parser("view_post/2219564123.post_not_found.html")
    expect(parser.post_not_found?).to eq(true)
  end

  def get_parser(file)
    Domain::Sofurry::PostPageParser.new(
      File.read(Rails.root.join("test/fixtures/files/domain/sofurry/#{file}")),
      require_logged_in: false,
    )
  end
end
