Sha256: dc42e772a3660af4ee66b5b066ad61b88f983876416c1f04d0f801037858b9a8

Contents?: true

Size: 918 Bytes

Versions: 18

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

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

  describe '#items' do
    it 'is the array of items with display set to true' do
      block_data[:item] = {
        '0': { id: 'abc123', display: 'true' },
        '1': { id: 'xyz321', display: 'false' }
      }
      expect(subject.items.length).to eq 1
      expect(subject.items).to eq([{ id: 'abc123', display: 'true' }])
    end

    it 'is an empty array when there is no browse category' do
      expect(subject.items).to eq([])
    end
  end

  describe '#as_json' do
    context 'when no items are present' do
      it 'returns an empty items value' do
        block_data[:item] = nil
        expect(subject.as_json[:data]).to include item: {}
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-3.0.0.alpha.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.13.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.12.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.12.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.11.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.10.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.9.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.8.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.7.2 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.7.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.7.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.6.1.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.6.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.6.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.5.2 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.5.1 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb
blacklight-spotlight-2.5.0 spec/models/sir_trevor_rails/blocks/featured_pages_block_spec.rb