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.40.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.39.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.38.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.2.2 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.2.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.2.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.37.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.36.2 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.36.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.36.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.35.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.1.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-7.34.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.1 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta8 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta7 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta6 spec/components/blacklight/metadata_field_component_spec.rb
blacklight-8.0.0.beta5 spec/components/blacklight/metadata_field_component_spec.rb