Sha256: c462a2ea03f2e34ae6bae776c978518a5227709b1def878b0492aaad790061f0

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

RSpec.describe Blacklight::Icon do
  subject { described_class.new(:search, classes: 'awesome') }

  describe '#svg' do
    it 'returns a string' do
      expect(subject.svg).to be_an String
    end
    it 'returns raw svg' do
      expect(Capybara.string(subject.svg))
        .to have_css 'svg title', text: 'Search'
    end
  end

  describe '#options' do
    it 'applies options classes and default class' do
      expect(subject.options[:class]).to eq 'blacklight-icons awesome'
    end
  end

  describe '#path' do
    it 'prepends blacklight and sufixes .svg' do
      expect(subject.path).to eq 'blacklight/search.svg'
    end
  end

  describe 'file_source' do
    context 'file is not available' do
      subject { described_class.new(:yolo) }

      it {
        expect { subject.file_source }
          .to raise_error(Blacklight::Exceptions::IconNotFound)
      }
    end

    context 'file is available' do
      it 'returns the filesource' do
        expect(subject.file_source).to include '<svg'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
blacklight-7.1.0.alpha spec/models/blacklight/icon_spec.rb
blacklight-7.0.1 spec/models/blacklight/icon_spec.rb
blacklight-7.0.0 spec/models/blacklight/icon_spec.rb
blacklight-7.0.0.rc2 spec/models/blacklight/icon_spec.rb