spec/helpers/geoblacklight_helper_spec.rb in geoblacklight-2.4.0 vs spec/helpers/geoblacklight_helper_spec.rb in geoblacklight-3.0.0
- old
+ new
@@ -1,16 +1,17 @@
+# frozen_string_literal: true
require 'spec_helper'
describe GeoblacklightHelper, type: :helper do
include BlacklightHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::TranslationHelper
describe '#render_facet_links' do
let(:subject_field) { Settings.FIELDS.SUBJECT }
it 'contains unique links' do
expect(self).to receive(:search_catalog_path).exactly(3).times.and_return("http://example.com/catalog?f[#{subject_field}][]=category")
- html = Capybara.string(render_facet_links(subject_field, %w(Test Test Earth Science)))
+ html = Capybara.string(render_facet_links(subject_field, %w[Test Test Earth Science]))
expect(html).to have_css 'a', count: 3
expect(html).to have_css 'a', text: 'Test', count: 1
expect(html).to have_css 'a', text: 'Earth', count: 1
expect(html).to have_css 'a', text: 'Science', count: 1
end
@@ -50,10 +51,21 @@
it 'returns download text concatenated with proper case format' do
expect(download_text('GEOJSON')).to eq 'Original GeoJSON'
end
end
+ describe '#download_link_file' do
+ let(:label) { 'Test Link Text' }
+ let(:id) { 'test-id' }
+ let(:url) { 'http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip' }
+
+ it 'generates a link to download the original file' do
+ puts download_link_file(label, id, url)
+ expect(download_link_file(label, id, url)).to eq '<a contentUrl="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip" class="btn btn-default download download-original" data-download="trigger" data-download-type="direct" data-download-id="test-id" href="http://example.com/urn:hul.harvard.edu:HARVARD.SDE2.TG10USAIANNH/data.zip">Test Link Text</a>'
+ end
+ end
+
describe '#download_link_direct' do
let(:text) { 'Test Link Text' }
let(:references_field) { Settings.FIELDS.REFERENCES }
let(:document_attributes) do
{
@@ -183,11 +195,11 @@
end
end
context 'as a multivalued Array' do
let(:document_attributes) do
{
- value: %w(short description)
+ value: %w[short description]
}
end
it 'uses both values' do
expect(helper.snippit(document)).to eq 'short description'
end
@@ -202,13 +214,13 @@
before do
allow(helper).to receive(:application_name).and_return('GeoBlacklight')
end
- describe '#cartodb_link' do
+ describe '#carto_link' do
it 'aliases CartoHelper#carto_link' do
- expect(helper.cartodb_link('http://demo.org/wfs/layer.json')).to eq(helper.carto_link('http://demo.org/wfs/layer.json'))
+ expect(helper.carto_link('http://demo.org/wfs/layer.json')).to eq(helper.carto_link('http://demo.org/wfs/layer.json'))
end
end
end
describe '#render_web_services' do
@@ -238,11 +250,11 @@
end
end
describe '#render_value_as_truncate_abstract' do
context 'with multiple values' do
- let(:document) { SolrDocument.new(value: %w(short description)) }
+ let(:document) { SolrDocument.new(value: %w[short description]) }
it 'wraps in correct DIV class' do
expect(helper.render_value_as_truncate_abstract(document)).to eq '<div class="truncate-abstract">short description</div>'
end
end
end
@@ -326,17 +338,38 @@
end
end
end
describe '#relations_icon' do
- it 'renders a goemetry type if configured' do
- allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(true)
- html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
- expect(html.title.strip).to eq 'Polygon'
+ context 'when configured to use the geometry type' do
+ before do
+ allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(true)
+ end
+
+ it 'renders a goemetry type as the icon' do
+ html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
+ expect(html.title.strip).to eq 'Polygon'
+ end
+
+ it 'has the svg_tooltip class so that the Bootstrap tooltip is applied' do
+ html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
+ expect(html).to have_css('.blacklight-icons.svg_tooltip')
+ end
end
- it 'renders provided icon if not configured to use geometry' do
- allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(false)
- html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
- expect(html.title.strip).to eq 'Leaf'
+
+ context 'when not confiugred to use the geometry type' do
+ before do
+ allow(Settings).to receive(:USE_GEOM_FOR_RELATIONS_ICON).and_return(false)
+ end
+
+ it 'renders the provided icon' do
+ html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
+ expect(html.title.strip).to eq 'Leaf'
+ end
+
+ it 'does not have the svg_tooltip class' do
+ html = Capybara.string(helper.relations_icon({ 'layer_geom_type_s' => 'polygon' }, 'leaf'))
+ expect(html).not_to have_css('.blacklight-icons.svg_tooltip')
+ end
end
end
end