Browse Source

Update tests to use translation

pull/2694/head
Manny Dinssa 8 months ago
parent
commit
839846325d
  1. 3
      app/helpers/formatting_helper.rb
  2. 4
      spec/models/form/sales/questions/uprn_confirmation_spec.rb
  3. 4
      spec/models/form/sales/questions/uprn_known_spec.rb

3
app/helpers/formatting_helper.rb

@ -2,7 +2,8 @@ module FormattingHelper
def format_ending(text)
return text if text.blank?
modified_text = lowercase_first_letter(text)
first_word = text.split.first
modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text)
ensure_sentence_ending(modified_text)
end

4
spec/models/form/sales/questions/uprn_confirmation_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do
include FormattingHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -24,7 +26,7 @@ RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do
end
it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must answer is this the right address?")
expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t("forms.2023.sales.property_information.uprn_confirmed.check_answer_label"))}")
end
describe "notification_banner" do

4
spec/models/form/sales/questions/uprn_known_spec.rb

@ -1,6 +1,8 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
include FormattingHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
@ -35,7 +37,7 @@ RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do
end
it "has the correct unanswered_error_message" do
expect(question.unanswered_error_message).to eq("You must answer UPRN known?")
expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t("forms.2023.sales.property_information.uprn.uprn_known.check_answer_label"))}")
end
it "has the correct hidden_in_check_answers" do

Loading…
Cancel
Save