Sha256: 267de135acf320ffae2b4dd5f85fbcb83e73c06270830bbd851afb25e71c0849

Contents?: true

Size: 1.73 KB

Versions: 5

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

describe Spotlight::TitleHelper, type: :helper do
  before do
    allow(helper).to receive_messages(application_name: 'Application')
  end

  describe '#page_title' do
    it 'sets the @page_title ivar' do
      helper.page_title('Section', 'Title')
      title = helper.instance_variable_get(:@page_title)
      expect(title).to eq 'Section - Title | Application'
    end

    it 'renders the section title and the page title' do
      title = helper.page_title('Section', 'Title')
      expect(title).to have_selector 'h1', text: 'Section'
      expect(title).to have_selector 'h1 small', text: 'Title'
    end
  end

  describe '#set_html_page_title' do
    it 'assigns the @page_title ivar' do
      allow(helper).to receive_messages(application_name: 'B')
      helper.set_html_page_title 'A'
      title = helper.instance_variable_get(:@page_title)
      expect(title).to eq 'A | B'
    end

    it 'strips out any HTML tags' do
      allow(helper).to receive_messages(application_name: 'B')
      expect(helper.set_html_page_title('<b>text</b> should not include HTML')).to eq 'text should not include HTML | B'
    end
  end

  describe '#curation_page_title' do
    it 'renders a page title in the curation section' do
      title = helper.curation_page_title 'Some title'
      expect(title).to have_selector 'h1', text: 'Curation'
      expect(title).to have_selector 'h1 small', text: 'Some title'
    end
  end

  describe '#configuration_page_title' do
    it 'renders a page title in the configuration section' do
      title = helper.configuration_page_title 'Some title'
      expect(title).to have_selector 'h1', text: 'Configuration'
      expect(title).to have_selector 'h1 small', text: 'Some title'
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.7 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-3.0.0.alpha.6 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-3.0.0.alpha.5 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-3.0.0.alpha.4 spec/helpers/spotlight/title_helper_spec.rb
blacklight-spotlight-3.0.0.alpha.3 spec/helpers/spotlight/title_helper_spec.rb