Skip to content

Commit

Permalink
SRCH-2308 add specs for NewsSearchHelper#current_time_filter_descript…
Browse files Browse the repository at this point in the history
…ion (#735)
  • Loading branch information
MothOnMars authored Jun 4, 2021
1 parent 0a297ef commit 129d71f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions spec/helpers/news_search_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,45 @@
end
end
end

describe '#current_time_filter_description' do
subject(:current_time_filter_description) do
helper.current_time_filter_description(search)
end

let(:tbs) { nil }
let(:since) { nil }
let(:until_time) { nil }
let(:search) do
instance_double(NewsSearch, tbs: tbs, since: since, until: until_time)
end

it { is_expected.to eq 'Any time' }

context 'when searching by the most recent month' do
let(:tbs) { 'm' }

it { is_expected.to eq 'Last month' }
end

context 'when searching after a time' do
let(:since) { Time.utc(2021, 5, 1) }

before { travel_to(Time.utc(2021, 6, 3)) }

after { travel_back }

it 'describes a range from the given date to the current date' do
expect(current_time_filter_description).to eq 'May 1, 2021 - Jun 3, 2021'
end
end

context 'when searching before a time' do
let(:until_time) { Time.utc(2021, 6, 3) }

it 'describes a range up to the given date' do
expect(current_time_filter_description).to eq 'Before Jun 3, 2021'
end
end
end
end

0 comments on commit 129d71f

Please sign in to comment.