Browse Source

tests for scheme_items

pull/669/head
JG 3 years ago
parent
commit
fc50d84aef
  1. 2
      app/helpers/navigation_items_helper.rb
  2. 31
      spec/helpers/navigation_items_helper_spec.rb

2
app/helpers/navigation_items_helper.rb

@ -36,7 +36,7 @@ module NavigationItemsHelper
def scheme_items(path, current_scheme_id, title)
[
NavigationItem.new("Schemes", "/schemes/#{current_scheme_id}", !path.include?("locations")),
NavigationItem.new("Scheme", "/schemes/#{current_scheme_id}", !path.include?("locations")),
NavigationItem.new(title, "/schemes/#{current_scheme_id}/locations", path.include?("locations")),
]
end

31
spec/helpers/navigation_items_helper_spec.rb

@ -187,8 +187,39 @@ RSpec.describe NavigationItemsHelper do
]
end
let(:expected_scheme_items) do
[
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", true),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", false),
]
end
it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1", 1, "1 location")).to eq(expected_scheme_items)
end
end
context "when the user is on the scheme locations page" do
let(:expected_navigation_items) do
[
NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false),
NavigationItemsHelper::NavigationItem.new("Users", "/users", false),
NavigationItemsHelper::NavigationItem.new("Logs", "/logs", false),
NavigationItemsHelper::NavigationItem.new("Schemes", "/schemes", true),
]
end
let(:expected_scheme_items) do
[
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", false),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", true),
]
end
it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1/locations", 1, "1 location")).to eq(expected_scheme_items)
end
end

Loading…
Cancel
Save