-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
131b5e4
commit e11022c
Showing
5 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,75 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe Web::Views::Vacancies::Index, type: :view do | ||
let(:exposures) { Hash[format: :html] } | ||
let(:params) { Hash[] } | ||
let(:exposures) { Hash[format: :html, flash: {}, vacancies: [], params: params] } | ||
let(:template) { Hanami::View::Template.new('apps/web/templates/vacancies/index.html.slim') } | ||
let(:view) { described_class.new(template, exposures) } | ||
let(:rendered) { view.render } | ||
|
||
it 'exposes #format' do | ||
expect(view.format).to eq exposures.fetch(:format) | ||
end | ||
|
||
describe 'remote radiobuttons' do | ||
let(:rendered) { without_indentation(view.render) } | ||
|
||
before { allow(view).to receive(:pagination) } | ||
|
||
it do | ||
expect(rendered).to include without_indentation <<~HTML | ||
<div class="btn-group btn-group-toggle"> | ||
<a class="btn btn-light active"><span>Любые</span></a> | ||
<a class="btn btn-light" href="/?remote=true"><span>Удаленные</span></a> | ||
<a class="btn btn-light" href="/?remote=false"><span>В офисе</span></a> | ||
</div> | ||
HTML | ||
end | ||
|
||
context 'when remote is true' do | ||
let(:params) { Hash[remote: 'true'] } | ||
|
||
it do | ||
expect(rendered).to include without_indentation <<~HTML | ||
<div class="btn-group btn-group-toggle"> | ||
<a class="btn btn-light" href="/"><span>Любые</span></a> | ||
<a class="btn btn-light active"><span>Удаленные</span></a> | ||
<a class="btn btn-light" href="/?remote=false"><span>В офисе</span></a> | ||
</div> | ||
HTML | ||
end | ||
end | ||
|
||
context 'when remote is false' do | ||
let(:params) { Hash[remote: 'false'] } | ||
|
||
it do | ||
expect(rendered).to include without_indentation <<~HTML | ||
<div class="btn-group btn-group-toggle"> | ||
<a class="btn btn-light" href="/"><span>Любые</span></a> | ||
<a class="btn btn-light" href="/?remote=true"><span>Удаленные</span></a> | ||
<a class="btn btn-light active"><span>В офисе</span></a> | ||
</div> | ||
HTML | ||
end | ||
end | ||
|
||
context 'when remote is not valid' do | ||
let(:params) { Hash[remote: 'foo'] } | ||
|
||
it do | ||
expect(rendered).to include without_indentation <<~HTML | ||
<div class="btn-group btn-group-toggle"> | ||
<a class="btn btn-light active"><span>Любые</span></a> | ||
<a class="btn btn-light" href="/?remote=true"><span>Удаленные</span></a> | ||
<a class="btn btn-light" href="/?remote=false"><span>В офисе</span></a> | ||
</div> | ||
HTML | ||
end | ||
end | ||
end | ||
|
||
def without_indentation(string) | ||
string.strip.gsub("\n", '') | ||
end | ||
end |