Browse Source

feat: update tests

pull/2214/head
natdeanlewissoftwire 2 years ago
parent
commit
3fe073b08b
  1. 12
      spec/models/form/lettings/questions/starter_tenancy_type_spec.rb
  2. 20
      spec/models/form/lettings/questions/tenancy_type_spec.rb

12
spec/models/form/lettings/questions/starter_tenancy_type_spec.rb

@ -14,11 +14,15 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
allow(subsection).to receive(:form).and_return(form) allow(subsection).to receive(:form).and_return(form)
end end
context "with collection year before 2024" do context "with 2023/24 form" do
before do before do
allow(form).to receive(:start_year_after_2024?).and_return(false) allow(form).to receive(:start_year_after_2024?).and_return(false)
end end
it "has the correct check answer label" do
expect(question.check_answer_label).to eq("Type of main tenancy after the starter period has ended?")
end
it "has the correct hint_text" do it "has the correct hint_text" do
expect(question.hint_text).to eq("This is also known as an ‘introductory period’.") expect(question.hint_text).to eq("This is also known as an ‘introductory period’.")
end end
@ -52,11 +56,15 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do
end end
end end
context "with collection year >= 2024" do context "with 2024/25 form" do
before do before do
allow(form).to receive(:start_year_after_2024?).and_return(true) allow(form).to receive(:start_year_after_2024?).and_return(true)
end end
it "has the correct check answer label" do
expect(question.check_answer_label).to eq("What is the type of tenancy after the starter or introductory period has ended")
end
it "has the correct updated hint_text" do it "has the correct updated hint_text" do
expect(question.hint_text).to eq("") expect(question.hint_text).to eq("")
end end

20
spec/models/form/lettings/questions/tenancy_type_spec.rb

@ -42,8 +42,13 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
end end
context "with 2023/24 form" do context "with 2023/24 form" do
it "has the correct answer_options" do before do
expect(question.answer_options).to eq({ allow(form).to receive(:start_year_after_2024?).and_return(false)
end
it "has the correct answer options" do
expect(question.answer_options).to eq(
{
"4" => { "4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term", "value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.", "hint" => "Mostly housing associations provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
@ -65,7 +70,8 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
"3" => { "3" => {
"value" => "Other", "value" => "Other",
}, },
}) },
)
end end
end end
@ -74,8 +80,9 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
allow(form).to receive(:start_year_after_2024?).and_return(true) allow(form).to receive(:start_year_after_2024?).and_return(true)
end end
it "has the correct answer_options" do it "has the correct answer options" do
expect(question.answer_options).to eq({ expect(question.answer_options).to eq(
{
"4" => { "4" => {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term", "value" => "Assured Shorthold Tenancy (AST) – Fixed term",
"hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.", "hint" => "These are mostly provided by housing associations. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
@ -101,7 +108,8 @@ RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do
"3" => { "3" => {
"value" => "Other", "value" => "Other",
}, },
}) },
)
end end
end end

Loading…
Cancel
Save