Sha256: 96f5ff520ae3071666be21521fe54f6bf54e98a8d30a04c0006258cea2ad881f

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module Decidim
  module Admin
    describe AriaSelectedLinkToHelper do
      let(:options) { {} }
      subject do
        Nokogiri::HTML(
          helper.aria_selected_link_to("Text", "url", options)
        )
      end

      context "with options" do
        let(:options) { { class: "my_class" } }

        it "still uses the options hash" do
          expect(subject.css("a[class='my_class']")).not_to be_empty
        end
      end

      context "when it's ponting to the current path" do
        before do
          expect(helper)
            .to receive(:is_active_link?)
            .and_return true
        end

        it "adds the attribute with 'true' as value" do
          expect(subject.css("a[href='url'][aria-selected='true']")).not_to be_empty
        end
      end

      context "when it's ponting to the current path" do
        before do
          expect(helper)
            .to receive(:is_active_link?)
            .and_return false
        end

        it "adds the attribute with 'false' as value" do
          expect(subject.css("a[href='url'][aria-selected='false']")).not_to be_empty
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/helpers/aria_selected_link_to_helper_spec.rb