From 06661bbfefef00ae3490a225f938c4031911827c Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 20 Mar 2024 08:48:06 -0400 Subject: [PATCH] Add specs for _mfa_selection recommended tag --- .../_mfa_selection.html.erb_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/views/partials/multi_factor_authentication/_mfa_selection.html.erb_spec.rb b/spec/views/partials/multi_factor_authentication/_mfa_selection.html.erb_spec.rb index b49110b4fe5..51601258751 100644 --- a/spec/views/partials/multi_factor_authentication/_mfa_selection.html.erb_spec.rb +++ b/spec/views/partials/multi_factor_authentication/_mfa_selection.html.erb_spec.rb @@ -12,6 +12,8 @@ let(:form_builder) do SimpleForm::FormBuilder.new(form_object.model_name.param_key, form_object, view_context, {}) end + let(:option) { presenter.options.first } + subject(:rendered) { render(partial: 'mfa_selection', locals: { form: form_builder, option: }) } context 'before selecting options' do subject(:rendered) do @@ -143,4 +145,20 @@ ) end end + + describe 'recommended tag' do + it 'does not render recommended tag' do + expect(rendered).not_to have_css('.usa-tag', text: t('two_factor_authentication.recommended')) + end + + context 'when option is recommended' do + before do + allow(option).to receive(:recommended?).and_return(true) + end + + it 'renders with recommended tag' do + expect(rendered).to have_css('.usa-tag', text: t('two_factor_authentication.recommended')) + end + end + end end