4 changed files with 186 additions and 0 deletions
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::AddressSearch, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1))) } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[uprn]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("address_search") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{"is_supported_housing?" => false, "manual_address_entry_selected" => false}]) |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(page.question_number).to eq(12) |
||||
end |
||||
end |
@ -0,0 +1,60 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::AddressSearch, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)))) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("uprn") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("address_search") |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(12) |
||||
end |
||||
|
||||
describe "get_extra_check_answer_value" do |
||||
context "when address is not present" do |
||||
let(:log) { build(:lettings_log, manual_address_entry_selected: false) } |
||||
|
||||
it "returns nil" do |
||||
expect(question.get_extra_check_answer_value(log)).to be_nil |
||||
end |
||||
end |
||||
|
||||
context "when address search is present" do |
||||
let(:log) do |
||||
build( |
||||
:lettings_log, |
||||
:completed, |
||||
address_line1: "19, Charlton Gardens", |
||||
town_or_city: "Bristol", |
||||
postcode_full: "BS10 6LU", |
||||
la: "E06000023", |
||||
uprn_known: 1, |
||||
uprn: 107, |
||||
uprn_confirmed: 1, |
||||
) |
||||
end |
||||
|
||||
context "when uprn known" do |
||||
|
||||
it "returns formatted value" do |
||||
expect(question.get_extra_check_answer_value(log)).to eq( |
||||
"\n\n19, Charlton Gardens\nBristol\nBS10 6LU\nBristol, City of", |
||||
) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AddressSearch, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1))) } |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[uprn]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("address_search") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ "manual_address_entry_selected" => false }]) |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(page.question_number).to eq(15) |
||||
end |
||||
end |
@ -0,0 +1,60 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::AddressSearch, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2025, 4, 1)))) } |
||||
|
||||
it "has correct page" do |
||||
expect(question.page).to eq(page) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(question.id).to eq("uprn") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("address_search") |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(15) |
||||
end |
||||
|
||||
describe "get_extra_check_answer_value" do |
||||
context "when address is not present" do |
||||
let(:log) { build(:sales_log, manual_address_entry_selected: false) } |
||||
|
||||
it "returns nil" do |
||||
expect(question.get_extra_check_answer_value(log)).to be_nil |
||||
end |
||||
end |
||||
|
||||
context "when address search is present" do |
||||
let(:log) do |
||||
build( |
||||
:sales_log, |
||||
:completed, |
||||
address_line1: "19, Charlton Gardens", |
||||
town_or_city: "Bristol", |
||||
postcode_full: "BS10 6LU", |
||||
la: "E06000023", |
||||
uprn_known: 1, |
||||
uprn: 107, |
||||
uprn_confirmed: 1, |
||||
) |
||||
end |
||||
|
||||
context "when uprn known" do |
||||
|
||||
it "returns formatted value" do |
||||
expect(question.get_extra_check_answer_value(log)).to eq( |
||||
"\n\n19, Charlton Gardens\nBristol\nBS10 6LU\nBristol, City of", |
||||
) |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue