Sha256: 5dd7a8c348ce42ba5615255dd3602cc904cedfd5eb6b2f85fab0dd9a117af51a

Contents?: true

Size: 1.84 KB

Versions: 2

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

describe SirTrevorRails::Blocks::SolrDocumentsBlock do
  let(:page) { FactoryBot.create(:feature_page) }
  let(:block_data) { {} }
  subject { described_class.new({ type: '', data: block_data }, page) }

  describe '#text' do
    it "is the block's text data" do
      block_data[:text] = 'abc'

      expect(subject.text).to eq 'abc'
    end

    it "squelches sir-trevor's placeholder values" do
      block_data[:text] = '<p><br></p>'
      expect(subject.text).to be_blank
    end
  end

  describe '#primary_caption?' do
    it 'is false if the primary caption field is not configured' do
      block_data['show-primary-caption'] = 'true'
      expect(subject.primary_caption?).to eq false
    end

    it 'is false if the field is configured not to show' do
      block_data['primary-caption-field'] = 'some_field'
      block_data['show-primary-caption'] = 'false'
      expect(subject.primary_caption?).to eq false
    end

    it 'is true if the field is configured to show' do
      block_data['primary-caption-field'] = 'some_field'
      block_data['show-primary-caption'] = 'true'
      expect(subject.primary_caption?).to eq true
    end
  end

  describe '#secondary_caption?' do
    it 'is false if the secondary caption field is not configured' do
      block_data['show-secondary-caption'] = 'true'
      expect(subject.secondary_caption?).to eq false
    end

    it 'is false if the field is configured not to show' do
      block_data['secondary-caption-field'] = 'some_field'
      block_data['show-secondary-caption'] = 'false'
      expect(subject.secondary_caption?).to eq false
    end

    it 'is true if the field is configured to show' do
      block_data['secondary-caption-field'] = 'some_field'
      block_data['show-secondary-caption'] = 'true'
      expect(subject.secondary_caption?).to eq true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb