You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
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
|
|
|