Files
nairobi/spec/components/admin/search_component_spec.rb
dependabot[bot] af0128860f Bump view_component from 2.78.0 to 3.5.0
Note version 3.0 removed the `controller` and `request` methods used in
component tests, introducing `vc_test_controller` and `vc_test_request`
instead.

Bumps [view_component](https://github.com/viewcomponent/view_component) from 2.78.0 to 3.5.0.
- [Release notes](https://github.com/viewcomponent/view_component/releases)
- [Changelog](https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/viewcomponent/view_component/compare/v2.78.0...v3.5.0)

---
updated-dependencies:
- dependency-name: view_component
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 14:17:36 +02:00

32 lines
1.1 KiB
Ruby

require "rails_helper"
describe Admin::SearchComponent do
describe "#hidden_current_filter_tag" do
context "controller responds to current_filter", controller: ApplicationController do
it "is present when the controller has a current filter" do
allow(vc_test_controller).to receive(:current_filter).and_return("all")
render_inline Admin::SearchComponent.new(label: "Search")
expect(page).to have_field "filter", type: :hidden, with: "all"
end
it "is not present when the controller has no current filter" do
render_inline Admin::SearchComponent.new(label: "Search")
expect(page).not_to have_field "filter", type: :hidden
expect(page).not_to have_field "filter"
end
end
context "controller does not respond to current_filter", controller: ActionController::Base do
it "is not present" do
render_inline Admin::SearchComponent.new(label: "Search")
expect(page).not_to have_field "filter", type: :hidden
expect(page).not_to have_field "filter"
end
end
end
end