Browse Source

Update tests

pull/2674/head
Manny Dinssa 2 years ago
parent
commit
195b05579e
  1. 66
      spec/models/form/question_spec.rb

66
spec/models/form/question_spec.rb

@ -377,91 +377,91 @@ RSpec.describe Form::Question, type: :model do
end end
describe "#error_display_label" do describe "#error_display_label" do
let(:question_with_error_label_no_punctuation) { described_class.new("address_line1_input", { "header" => "Address line 1", "error_label" => "Address line 1" }, page) } let(:question_with_error_label_no_punctuation) { described_class.new("address_line1_input", { "header" => "address line 1", "error_label" => "address line 1" }, page) }
let(:question_with_error_label_with_full_stop) { described_class.new("address_line1_input", { "header" => "Address line 1", "error_label" => "Address line 1." }, page) } let(:question_with_error_label_with_full_stop) { described_class.new("address_line1_input", { "header" => "address line 1", "error_label" => "address line 1." }, page) }
let(:question_with_error_label_with_question_mark) { described_class.new("address_line1_input", { "header" => "Address line 1", "error_label" => "Address line 1?" }, page) } let(:question_with_error_label_with_question_mark) { described_class.new("address_line1_input", { "header" => "address line 1", "error_label" => "address line 1?" }, page) }
let(:question_with_error_label_with_brackets) { described_class.new("address_line1_input", { "header" => "Address line 1", "error_label" => "(Address line 1)" }, page) } let(:question_with_error_label_with_brackets) { described_class.new("address_line1_input", { "header" => "address line 1", "error_label" => "(address line 1)" }, page) }
let(:question_with_error_label_with_percentage) { described_class.new("address_line1_input", { "header" => "Address line 1", "error_label" => "Address line 1%" }, page) } let(:question_with_error_label_with_percentage) { described_class.new("address_line1_input", { "header" => "address line 1", "error_label" => "address line 1%" }, page) }
let(:question_with_check_answer_label_no_punctuation) { described_class.new("address_line1_input", { "header" => "Address line 1", "check_answer_label" => "Address line 1" }, page) } let(:question_with_check_answer_label_no_punctuation) { described_class.new("address_line1_input", { "header" => "address line 1", "check_answer_label" => "address line 1" }, page) }
let(:question_with_check_answer_label_with_full_stop) { described_class.new("address_line1_input", { "header" => "Address line 1", "check_answer_label" => "Address line 1." }, page) } let(:question_with_check_answer_label_with_full_stop) { described_class.new("address_line1_input", { "header" => "address line 1", "check_answer_label" => "address line 1." }, page) }
let(:question_with_check_answer_label_with_question_mark) { described_class.new("address_line1_input", { "header" => "Address line 1", "check_answer_label" => "Address line 1?" }, page) } let(:question_with_check_answer_label_with_question_mark) { described_class.new("address_line1_input", { "header" => "address line 1", "check_answer_label" => "address line 1?" }, page) }
let(:question_with_check_answer_label_with_brackets) { described_class.new("address_line1_input", { "header" => "Address line 1", "check_answer_label" => "(Address line 1)" }, page) } let(:question_with_check_answer_label_with_brackets) { described_class.new("address_line1_input", { "header" => "address line 1", "check_answer_label" => "(address line 1)" }, page) }
let(:question_with_check_answer_label_with_percentage) { described_class.new("address_line1_input", { "header" => "Address line 1", "check_answer_label" => "Address line 1%" }, page) } let(:question_with_check_answer_label_with_percentage) { described_class.new("address_line1_input", { "header" => "address line 1", "check_answer_label" => "address line 1%" }, page) }
let(:question_with_header_no_punctuation) { described_class.new("address_line1_input", { "header" => "Address line 1" }, page) } let(:question_with_header_no_punctuation) { described_class.new("address_line1_input", { "header" => "address line 1" }, page) }
let(:question_with_header_with_full_stop) { described_class.new("address_line1_input", { "header" => "Address line 1." }, page) } let(:question_with_header_with_full_stop) { described_class.new("address_line1_input", { "header" => "address line 1." }, page) }
let(:question_with_header_with_question_mark) { described_class.new("address_line1_input", { "header" => "Address line 1?" }, page) } let(:question_with_header_with_question_mark) { described_class.new("address_line1_input", { "header" => "address line 1?" }, page) }
let(:question_with_header_with_brackets) { described_class.new("address_line1_input", { "header" => "(Address line 1)" }, page) } let(:question_with_header_with_brackets) { described_class.new("address_line1_input", { "header" => "(address line 1)" }, page) }
let(:question_with_header_with_percentage) { described_class.new("address_line1_input", { "header" => "Address line 1%" }, page) } let(:question_with_header_with_percentage) { described_class.new("address_line1_input", { "header" => "address line 1%" }, page) }
let(:question_with_id_only_no_punctuation) { described_class.new("address_line1_input", {}, page) } let(:question_with_id_only_no_punctuation) { described_class.new("address_line1_input", {}, page) }
context "when the error label should stay the same" do context "when the error label should stay the same" do
it "returns the error label unchanged with full stop" do it "returns the error label unchanged with full stop" do
expect(question_with_error_label_with_full_stop.error_display_label).to eq("Address line 1.") expect(question_with_error_label_with_full_stop.error_display_label).to eq("address line 1.")
end end
it "returns the error label unchanged with question mark" do it "returns the error label unchanged with question mark" do
expect(question_with_error_label_with_question_mark.error_display_label).to eq("Address line 1?") expect(question_with_error_label_with_question_mark.error_display_label).to eq("address line 1?")
end end
it "returns the check answer label unchanged with full stop" do it "returns the check answer label unchanged with full stop" do
expect(question_with_check_answer_label_with_full_stop.error_display_label).to eq("Address line 1.") expect(question_with_check_answer_label_with_full_stop.error_display_label).to eq("address line 1.")
end end
it "returns the check answer label unchanged with question mark" do it "returns the check answer label unchanged with question mark" do
expect(question_with_check_answer_label_with_question_mark.error_display_label).to eq("Address line 1?") expect(question_with_check_answer_label_with_question_mark.error_display_label).to eq("address line 1?")
end end
it "returns the header unchanged with full stop" do it "returns the header unchanged with full stop" do
expect(question_with_header_with_full_stop.error_display_label).to eq("Address line 1.") expect(question_with_header_with_full_stop.error_display_label).to eq("address line 1.")
end end
it "returns the header unchanged with question mark" do it "returns the header unchanged with question mark" do
expect(question_with_header_with_question_mark.error_display_label).to eq("Address line 1?") expect(question_with_header_with_question_mark.error_display_label).to eq("address line 1?")
end end
end end
context "when the error label should have a full stop added" do context "when the error label should have a full stop added" do
it "returns the error label with no punctuation changed to with a full stop" do it "returns the error label with no punctuation changed to with a full stop" do
expect(question_with_error_label_no_punctuation.error_display_label).to eq("Address line 1.") expect(question_with_error_label_no_punctuation.error_display_label).to eq("address line 1.")
end end
it "returns the error label with brackets changed to with a full stop" do it "returns the error label with brackets changed to with a full stop" do
expect(question_with_error_label_with_brackets.error_display_label).to eq("(Address line 1).") expect(question_with_error_label_with_brackets.error_display_label).to eq("(address line 1).")
end end
it "returns the error label with percentage changed to with a full stop" do it "returns the error label with percentage changed to with a full stop" do
expect(question_with_error_label_with_percentage.error_display_label).to eq("Address line 1%.") expect(question_with_error_label_with_percentage.error_display_label).to eq("address line 1%.")
end end
it "returns the check answer label with no punctuation changed with a full stop" do it "returns the check answer label with no punctuation changed with a full stop" do
expect(question_with_check_answer_label_no_punctuation.error_display_label).to eq("Address line 1.") expect(question_with_check_answer_label_no_punctuation.error_display_label).to eq("address line 1.")
end end
it "returns the check answer label with brackets changed with a full stop" do it "returns the check answer label with brackets changed with a full stop" do
expect(question_with_check_answer_label_with_brackets.error_display_label).to eq("(Address line 1).") expect(question_with_check_answer_label_with_brackets.error_display_label).to eq("(address line 1).")
end end
it "returns the check answer label with percentage changed with a full stop" do it "returns the check answer label with percentage changed with a full stop" do
expect(question_with_check_answer_label_with_percentage.error_display_label).to eq("Address line 1%.") expect(question_with_check_answer_label_with_percentage.error_display_label).to eq("address line 1%.")
end end
it "returns the header with no punctuation changed with a full stop" do it "returns the header with no punctuation changed with a full stop" do
expect(question_with_header_no_punctuation.error_display_label).to eq("Address line 1.") expect(question_with_header_no_punctuation.error_display_label).to eq("address line 1.")
end end
it "returns the header with brackets changed with a full stop" do it "returns the header with brackets changed with a full stop" do
expect(question_with_header_with_brackets.error_display_label).to eq("(Address line 1).") expect(question_with_header_with_brackets.error_display_label).to eq("(address line 1).")
end end
it "returns the header with percentage changed with a full stop" do it "returns the header with percentage changed with a full stop" do
expect(question_with_header_with_percentage.error_display_label).to eq("Address line 1%.") expect(question_with_header_with_percentage.error_display_label).to eq("address line 1%.")
end end
it "returns the id with no punctuation changed with a full stop" do it "returns the id with no punctuation changed with a full stop" do
expect(question_with_id_only_no_punctuation.error_display_label).to eq("Address line1 input.") expect(question_with_id_only_no_punctuation.error_display_label).to eq("address line1 input.")
end end
end end
end end

Loading…
Cancel
Save