Browse Source

feat: add tests for availability text

pull/2061/head
natdeanlewissoftwire 1 year ago
parent
commit
5b27b6fff4
  1. 29
      spec/helpers/locations_helper_spec.rb
  2. 11
      spec/helpers/schemes_helper_spec.rb

29
spec/helpers/locations_helper_spec.rb

@ -214,6 +214,35 @@ RSpec.describe LocationsHelper do
expect(availability_attribute).to eq("Active from 1 April 2022") expect(availability_attribute).to eq("Active from 1 April 2022")
end end
context "when location was merged" do
context "when there is no startdate" do
it "displays merge date as availability date" do
location.update!(merge_date: Time.zone.local(2022, 4, 16))
availability_attribute = display_location_attributes(location).find { |x| x[:name] == "Availability" }[:value]
expect(availability_attribute).to eq("Active from 16 April 2022")
end
end
context "when the startdate is before the merge date" do
it "displays merge date as availability date" do
location.update!(startdate: Time.zone.local(2022, 4, 3), merge_date: Time.zone.local(2022, 4, 16))
availability_attribute = display_location_attributes(location).find { |x| x[:name] == "Availability" }[:value]
expect(availability_attribute).to eq("Active from 16 April 2022")
end
end
context "when the startdate is after the merge date" do
it "displays startdate as availability date" do
location.update!(startdate: Time.zone.local(2022, 5, 3), merge_date: Time.zone.local(2022, 4, 16))
availability_attribute = display_location_attributes(location).find { |x| x[:name] == "Availability" }[:value]
expect(availability_attribute).to eq("Active from 3 May 2022")
end
end
end
end end
context "with previous deactivations" do context "with previous deactivations" do

11
spec/helpers/schemes_helper_spec.rb

@ -303,6 +303,17 @@ RSpec.describe SchemesHelper do
expect(display_scheme_attributes(scheme)).to eq(attributes) expect(display_scheme_attributes(scheme)).to eq(attributes)
end end
end end
context "when scheme was merged from another organisation" do
before do
FactoryBot.create(:location, scheme:)
scheme.merge_date = Time.zone.local(2023, 1, 5)
end
it "returns correct availability" do
expect(display_scheme_attributes(scheme)).to include({ name: "Availability", value: "Active from 5 January 2023" })
end
end
end end
describe "edit_scheme_text" do describe "edit_scheme_text" do

Loading…
Cancel
Save