|
2 | 2 |
|
3 | 3 | describe RenderConstraintsHelper do |
4 | 4 |
|
| 5 | + let(:config) do |
| 6 | + Blacklight::Configuration.new do |config| |
| 7 | + config.add_facet_field 'type' |
| 8 | + end |
| 9 | + end |
| 10 | + |
5 | 11 | before do |
6 | 12 | # the helper methods below infer paths from the current route |
7 | 13 | controller.request.path_parameters["controller"] = 'catalog' |
|
18 | 24 |
|
19 | 25 | describe '#render_filter_element' do |
20 | 26 | before do |
21 | | - @config = Blacklight::Configuration.new do |config| |
22 | | - config.add_facet_field 'type' |
23 | | - end |
24 | | - helper.stub(:blacklight_config => @config) |
| 27 | + allow(helper).to receive(:blacklight_config).and_return(config) |
| 28 | + expect(helper).to receive(:facet_field_label).with('type').and_return("Item Type") |
25 | 29 | end |
| 30 | + subject { helper.render_filter_element('type', ['journal'], {:q=>'biz'}) } |
| 31 | + |
26 | 32 | it "should have a link relative to the current url" do |
27 | | - result = helper.render_filter_element('type', ['journal'], {:q=>'biz'}) |
28 | | - expect(result).to have_link "Remove constraint Type: journal", href: "/catalog?q=biz" |
| 33 | + expect(subject).to have_link "Remove constraint Item Type: journal", href: "/catalog?q=biz" |
| 34 | + expect(subject).to have_selector ".filterName", text: 'Item Type' |
29 | 35 | end |
30 | 36 | end |
31 | 37 |
|
32 | 38 | describe "#render_constraints_filters" do |
33 | 39 | before do |
34 | | - @config = Blacklight::Configuration.new do |config| |
35 | | - config.add_facet_field 'type' |
36 | | - end |
37 | | - helper.stub(:blacklight_config => @config) |
| 40 | + allow(helper).to receive(:blacklight_config).and_return(config) |
38 | 41 | end |
| 42 | + subject { helper.render_constraints_filters(:f=>{'type'=>['']}) } |
39 | 43 |
|
40 | 44 | it "should render nothing for empty facet limit param" do |
41 | | - rendered = helper.render_constraints_filters(:f=>{'type'=>['']}) |
42 | | - expect(rendered).to be_blank |
| 45 | + expect(subject).to be_blank |
43 | 46 | end |
44 | 47 | end |
45 | | - |
46 | 48 | end |
0 commit comments