2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-06-03 07:44:27 +02:00
|
|
|
describe Procedure::Card::ChampsComponent, type: :component do
|
|
|
|
describe 'render' do
|
|
|
|
let(:procedure) { create(:procedure, id: 1, types_de_champ_private:, types_de_champ_public:) }
|
|
|
|
let(:types_de_champ_private) { [] }
|
|
|
|
let(:types_de_champ_public) { [] }
|
|
|
|
before { procedure.validate(:publication) }
|
|
|
|
subject { render_inline(described_class.new(procedure: procedure)) }
|
|
|
|
|
|
|
|
context 'when no errors' do
|
|
|
|
it 'does not render' do
|
|
|
|
expect(subject).to have_selector('.fr-badge--warning', text: 'À faire')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when errors on types_de_champs_public' do
|
|
|
|
let(:types_de_champ_public) { [{ type: :drop_down_list, options: [] }] }
|
|
|
|
it 'does not render' do
|
|
|
|
expect(subject).to have_selector('.fr-badge--error', text: 'À modifier')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when errors on types_de_champs_private' do
|
|
|
|
let(:types_de_champ_private) { [{ type: :drop_down_list, options: [] }] }
|
|
|
|
|
|
|
|
it 'render the template' do
|
|
|
|
expect(subject).to have_selector('.fr-badge--warning', text: 'À faire')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|