test/govspeak_contacts_test.rb in govspeak-6.5.0 vs test/govspeak_contacts_test.rb in govspeak-6.5.1

- old
+ new

@@ -1,8 +1,8 @@ # encoding: UTF-8 -require 'test_helper' +require "test_helper" class GovspeakContactsTest < Minitest::Test def build_contact(attrs = {}) { content_id: attrs.fetch(:content_id, "4f3383e4-48a2-4461-a41d-f85ea8b89ba0"), @@ -17,45 +17,45 @@ street_address: "125 Kingsway", locality: "Holborn", region: "London", postal_code: "WC2B 6NH", world_location: "United Kingdom", - } - ] + }, + ], ), email_addresses: attrs.fetch( :email_addresses, [ { title: "", email: "people@digital.cabinet-office.gov.uk", - } - ] + }, + ], ), phone_numbers: attrs.fetch( :phone_numbers, [ { title: "helpdesk", number: "+4412345 67890", - } - ] + }, + ], ), contact_form_links: attrs.fetch( :contact_form_links, [ { - link: "https://www.gov.uk/contact" - } - ] - ) - } + link: "https://www.gov.uk/contact", + }, + ], + ), + }, } end def compress_html(html) - html.gsub(/[\n\r]+[\s]*/, '') + html.gsub(/[\n\r]+[\s]*/, "") end test "contact is rendered when present in options[:contacts]" do contact = build_contact govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" @@ -134,11 +134,11 @@ test "contact with United Kingdom country address doesn't show the country" do contact = build_contact(post_addresses: [ { street_address: "125 Kingsway", country_name: "United Kingdom", - } + }, ]) govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html expected = %{ <p class="adr"> @@ -150,43 +150,43 @@ test "contact with an empty postal address is not rendered" do contact = build_contact(post_addresses: [ { street_address: "", - } + }, ]) govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html refute_match(%{<p class="adr">}, compress_html(rendered)) end test "contact with an empty email address is not rendered" do contact = build_contact(email_addresses: [ { email: "", - } + }, ]) govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html refute_match(%{<p class="email">}, compress_html(rendered)) end test "contact with an empty contact form is not rendered" do contact = build_contact(contact_form_links: [ { link: "", - } + }, ]) govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html refute_match(%{<p class="contact_form_url">}, compress_html(rendered)) end test "contact with an empty phone number is not rendered" do contact = build_contact(phone_numbers: [ { number: "", - } + }, ]) govspeak = "[Contact:4f3383e4-48a2-4461-a41d-f85ea8b89ba0]" rendered = Govspeak::Document.new(govspeak, contacts: [contact]).to_html refute_match(%{<p class="tel">}, compress_html(rendered)) end