demarches-normaliennes/spec/helpers/admin_formulaire_helper.rb

63 lines
1.8 KiB
Ruby
Raw Normal View History

2018-12-27 14:22:04 +01:00
require 'rails_helper'
2018-12-27 14:22:04 +01:00
RSpec.describe AdminFormulaireHelper, type: :helper do
let(:procedure) { create(:procedure) }
2018-12-27 14:22:04 +01:00
let(:kind) { 'piece_justificative' }
let(:url) { 'http://localhost' }
let!(:type_de_piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
describe '#button_up' do
describe 'with first piece justificative' do
let(:index) { 0 }
it 'returns a button up' do
2018-12-27 14:22:04 +01:00
expect(button_up(procedure, kind, index, url)).to be(nil)
end
end
describe 'with second out of three piece justificative' do
let(:index) { 1 }
it 'returns a button up' do
2018-12-27 14:22:04 +01:00
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
end
end
describe 'with last piece justificative' do
let(:index) { 2 }
it 'returns a button up' do
2018-12-27 14:22:04 +01:00
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
end
2018-12-27 14:22:04 +01:00
end
end
describe '#button_down' do
describe 'with first piece justificative' do
let(:index) { 0 }
it 'returns a button down' do
2018-12-27 14:22:04 +01:00
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
end
end
describe 'with second out of three piece justificative' do
let(:index) { 1 }
it 'returns a button down' do
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
end
end
describe 'with last piece justificative' do
let(:index) { 2 }
it 'returns nil' do
expect(button_down(procedure, kind, index, url)).to be(nil)
end
end
end
2017-04-04 15:27:04 +02:00
end