-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update link_to_search to work with only one search_field
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Blacklight::SkipLinkComponent, type: :component do | ||
subject(:rendered) do | ||
render_inline_to_capybara_node(described_class.new) | ||
end | ||
|
||
before do | ||
allow(controller).to receive(:blacklight_config).and_return(blacklight_config) | ||
end | ||
|
||
context 'with no search fields' do | ||
let(:blacklight_config) do | ||
Blacklight::Configuration.new.configure do |config| | ||
config.search_fields = {} | ||
end | ||
end | ||
|
||
it 'renders skip links with correct link to search' do | ||
expect(rendered).to have_link("Skip to main content", href: '#main-container') | ||
expect(rendered).to have_link("Skip to search", href: "#q") | ||
end | ||
end | ||
|
||
context 'with one search field' do | ||
let(:blacklight_config) do | ||
Blacklight::Configuration.new.configure do |config| | ||
config.search_fields = { "all_fields" => "" } | ||
end | ||
end | ||
|
||
it 'renders skip links with correct link to search' do | ||
expect(rendered).to have_link("Skip to main content", href: "#main-container") | ||
expect(rendered).to have_link("Skip to search", href: "#q") | ||
end | ||
end | ||
|
||
context 'with two search field' do | ||
let(:blacklight_config) do | ||
Blacklight::Configuration.new.configure do |config| | ||
config.search_fields = { "all_fields" => "", "title_field" => "" } | ||
end | ||
end | ||
|
||
it 'renders skip links with correct link to search' do | ||
expect(rendered).to have_link("Skip to main content", href: "#main-container") | ||
expect(rendered).to have_link("Skip to search", href: "#search_field") | ||
end | ||
end | ||
end |