Sha256: d3a5b913cac28a8621b78c07dc4be218ac396d963d4e33d02fbd12cd623c3c48

Contents?: true

Size: 1.13 KB

Versions: 51

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Blacklight::MetadataFieldComponent, type: :component do
  subject(:rendered) do
    render_inline_to_capybara_node(described_class.new(field: field))
  end

  let(:view_context) { controller.view_context }
  let(:document) { SolrDocument.new('field' => ['Value']) }
  let(:field_config) { Blacklight::Configuration::Field.new(key: 'field', field: 'field', label: 'Field label') }

  let(:field) do
    Blacklight::FieldPresenter.new(view_context, document, field_config)
  end

  it 'renders the field label' do
    expect(rendered).to have_selector 'dt.blacklight-field', text: 'Field label'
  end

  it 'renders the field value' do
    expect(rendered).to have_selector 'dd.blacklight-field', text: 'Value'
  end

  context 'from a show view' do
    subject(:rendered) do
      render_inline_to_capybara_node(described_class.new(field: field, show: true))
    end

    it 'renders the right field label' do
      allow(field).to receive(:label).with('show').and_return('custom label')

      expect(rendered).to have_selector 'dt.blacklight-field', text: 'custom label'
    end
  end
end

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
blacklight-7.33.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta4 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta3 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta2 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.33.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.32.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.31.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.30.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.29.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.28.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.27.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.27.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.26.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.26.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.25.3 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.25.2 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.25.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.25.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.24.0 spec/components/blacklight/metadata_field_component_spec.rb