Browse Source

Tweak search result caption component

pull/795/head
Paul Robert Lloyd 3 years ago committed by baarkerlounger
parent
commit
5ca3129f07
  1. 4
      app/components/search_result_caption_component.html.erb
  2. 4
      spec/components/search_result_caption_component_spec.rb
  3. 2
      spec/requests/organisations_controller_spec.rb
  4. 6
      spec/requests/schemes_controller_spec.rb

4
app/components/search_result_caption_component.html.erb

@ -1,7 +1,7 @@
<span class="govuk-!-margin-right-4"> <span class="govuk-!-margin-right-4">
<% if searched.present? %> <% if searched.present? %>
<strong><%= count %></strong> <%= item_label %> found matching ‘<%= searched %>’ of <strong><%= total_count %></strong> total <%= item %>. <%= govuk_link_to("Clear search", path) %> <strong><%= count %></strong> <%= item_label %> found matching ‘<%= searched %>’ of <strong><%= total_count %></strong> total <%= item %>. <%= govuk_link_to("Clear search", path) %>
<% else %> <% else %>
<strong><%= count %></strong> total <%= item %>. <strong><%= count %></strong> total <%= item %>
<% end %> <% end %>
</span> </span>

4
spec/components/search_result_caption_component_spec.rb

@ -10,7 +10,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
it "renders table caption including the search results and total" do it "renders table caption including the search results and total" do
result = render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, path:)) result = render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, path:))
expect(result.to_html).to eq(" <span class=\"govuk-!-margin-right-4\">\n <strong>#{count}</strong> #{item_label} found matching ‘#{searched}’ of <strong>#{total_count}</strong> total #{item}. <a class=\"govuk-link\" href=\"path\">Clear search</a>\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>#{count}</strong> #{item_label} found matching ‘#{searched}’ of <strong>#{total_count}</strong> total #{item}. <a class=\"govuk-link\" href=\"path\">Clear search</a>\n</span>\n")
end end
context "when no search results are found" do context "when no search results are found" do
@ -19,7 +19,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
it "renders table caption with total count only" do it "renders table caption with total count only" do
result = render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, path:)) result = render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, path:))
expect(result.to_html).to eq(" <span class=\"govuk-!-margin-right-4\">\n <strong>#{count}</strong> total #{item}.\n</span>\n") expect(result.to_html).to eq("<span class=\"govuk-!-margin-right-4\">\n <strong>#{count}</strong> total #{item}\n</span>\n")
end end
end end
end end

2
spec/requests/organisations_controller_spec.rb

@ -892,7 +892,7 @@ RSpec.describe OrganisationsController, type: :request do
end end
it "shows the total organisations count" do it "shows the total organisations count" do
expect(CGI.unescape_html(response.body)).to match("<strong>#{total_organisations_count}</strong> total organisations.") expect(CGI.unescape_html(response.body)).to match("<strong>#{total_organisations_count}</strong> total organisations")
end end
it "has pagination links" do it "has pagination links" do

6
spec/requests/schemes_controller_spec.rb

@ -90,7 +90,7 @@ RSpec.describe SchemesController, type: :request do
end end
it "shows the total organisations count" do it "shows the total organisations count" do
expect(CGI.unescape_html(response.body)).to match("<strong>#{schemes.count}</strong> total schemes.") expect(CGI.unescape_html(response.body)).to match("<strong>#{schemes.count}</strong> total schemes")
end end
context "when params scheme_id is present" do context "when params scheme_id is present" do
@ -113,7 +113,7 @@ RSpec.describe SchemesController, type: :request do
end end
it "shows the total schemes count" do it "shows the total schemes count" do
expect(CGI.unescape_html(response.body)).to match("<strong>#{total_schemes_count}</strong> total schemes.") expect(CGI.unescape_html(response.body)).to match("<strong>#{total_schemes_count}</strong> total schemes")
end end
it "shows which schemes are being shown on the current page" do it "shows which schemes are being shown on the current page" do
@ -138,7 +138,7 @@ RSpec.describe SchemesController, type: :request do
end end
it "shows the total schemes count" do it "shows the total schemes count" do
expect(CGI.unescape_html(response.body)).to match("<strong>#{total_schemes_count}</strong> total schemes.") expect(CGI.unescape_html(response.body)).to match("<strong>#{total_schemes_count}</strong> total schemes")
end end
it "has pagination links" do it "has pagination links" do

Loading…
Cancel
Save