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. 108
      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

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

@ -42,30 +42,36 @@ 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)
"4" => { end
"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.", it "has the correct answer options" do
}, expect(question.answer_options).to eq(
"6" => { {
"value" => "Secure – fixed term", "4" => {
"hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.", "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.",
"2" => { },
"value" => "Assured – lifetime", "6" => {
}, "value" => "Secure – fixed term",
"7" => { "hint" => "Mostly local authorities provide these. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
"value" => "Secure – lifetime", },
}, "2" => {
"5" => { "value" => "Assured – lifetime",
"value" => "Licence agreement", },
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.", "7" => {
}, "value" => "Secure – lifetime",
"3" => { },
"value" => "Other", "5" => {
"value" => "Licence agreement",
"hint" => "Licence agreements are mostly used for Supported Housing and work on a rolling basis.",
},
"3" => {
"value" => "Other",
},
}, },
}) )
end end
end end
@ -74,34 +80,36 @@ 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" => { {
"value" => "Assured Shorthold Tenancy (AST) – Fixed term", "4" => {
"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.", "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.",
"6" => { },
"value" => "Secure – fixed term", "6" => {
"hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.", "value" => "Secure – fixed term",
}, "hint" => "These are mostly provided by local authorities. Fixed term tenancies are intended to be for a set amount of time up to 20 years.",
"2" => { },
"value" => "Assured – lifetime", "2" => {
}, "value" => "Assured – lifetime",
"7" => { },
"value" => "Secure – lifetime", "7" => {
}, "value" => "Secure – lifetime",
"8" => { },
"value" => "Periodic", "8" => {
"hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.", "value" => "Periodic",
}, "hint" => "These are rolling tenancies with no fixed end date. They may have an initial fixed term and then become rolling.",
"5" => { },
"value" => "Licence agreement", "5" => {
"hint" => "These are mostly used for Supported Housing and work on a rolling basis.", "value" => "Licence agreement",
}, "hint" => "These are mostly used for Supported Housing and work on a rolling basis.",
"3" => { },
"value" => "Other", "3" => {
"value" => "Other",
},
}, },
}) )
end end
end end

Loading…
Cancel
Save