Browse Source

create tests for pages

pull/1338/head
Arthur Campbell 3 years ago
parent
commit
4b6b48bad1
  1. 2
      app/models/form/lettings/pages/previous_housing_situation.rb
  2. 2
      app/models/form/lettings/pages/previous_housing_situation_renewal.rb
  3. 31
      spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb
  4. 31
      spec/models/form/lettings/pages/previous_housing_situation_spec.rb

2
app/models/form/lettings/pages/previous_housing_situation.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituation < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "previous_housing_situation" @id = "previous_housing_situation"
@depends_on = [{ "renewal" => 0 }] @depends_on = [{ "is_renewal?" => false }]
end end
def questions def questions

2
app/models/form/lettings/pages/previous_housing_situation_renewal.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituationRenewal < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "previous_housing_situation_renewal" @id = "previous_housing_situation_renewal"
@depends_on = [{ "renewal" => 1, "needstype" => 2 }] @depends_on = [{ "is_renewal?" => true, "is_supported_housing?" => true }]
end end
def questions def questions

31
spec/models/form/lettings/pages/previous_housing_situation_renewal_spec.rb

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PreviousHousingSituationRenewal, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
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[prevten])
end
it "has the correct id" do
expect(page.id).to eq("previous_housing_situation_renewal")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has the correct depends_on" do
expect(page.depends_on).to eq([{ "is_renewal?" => true, "is_supported_housing?" => true }])
end
end

31
spec/models/form/lettings/pages/previous_housing_situation_spec.rb

@ -0,0 +1,31 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PreviousHousingSituation, type: :model do
subject(:page) { described_class.new(nil, nil, subsection) }
let(:subsection) { instance_double(Form::Subsection) }
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[prevten])
end
it "has the correct id" do
expect(page.id).to eq("previous_housing_situation")
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "has the correct depends_on" do
expect(page.depends_on).to eq([{ "is_renewal?" => false }])
end
end
Loading…
Cancel
Save