require "rails_helper"

RSpec.describe PlansHelper, type: :helper do
  describe "#lock_icon_for" do
    it "returns an unlocked icon when account has access to the given product" do
      mesuite = build(:account, :mesuite)
      releaseme = build(:account, :releaseme)
      deliverme = build(:account, :deliverme)

      expect(helper.lock_icon_for(mesuite, :releaseme)).to match "unlock"
      expect(helper.lock_icon_for(mesuite, :deliverme)).to match "unlock"
      expect(helper.lock_icon_for(releaseme, :releaseme)).to match "unlock"
      expect(helper.lock_icon_for(deliverme, :deliverme)).to match "unlock"
    end

    it "returns a locked icon when the user does not have access to the given product" do
      no_releaseme = build(:account, :deliverme)
      no_deliverme = build(:account, :releaseme)

      expect(helper.lock_icon_for(no_releaseme, :releaseme)).to match "lock"
      expect(helper.lock_icon_for(no_deliverme, :deliverme)).to match "lock"
    end

    it "includes any passed in text" do
      releaseme = build(:account, :releaseme)

      expect(helper.lock_icon_for(releaseme, :releaseme, text: "Test")).to match "Test"
      expect(helper.lock_icon_for(releaseme, :deliverme, text: "Test")).to match "Test"

    end
  end
end
