Skip to content

Commit

Permalink
Add specs for BsRequestHistoryElementComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
saraycp committed Feb 28, 2023
1 parent 8b65c57 commit 149603f
Showing 1 changed file with 59 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,75 @@
require 'rails_helper'

RSpec.describe BsRequestHistoryElementComponent, type: :component do
# rubocop:disable Lint/EmptyBlock
shared_context 'raising an exception warning the user to provide an history element' do
end
# rubocop:enable Lint/EmptyBlock
let(:user) { create(:confirmed_user) }

# rubocop:disable RSpec/RepeatedExampleGroupBody
context 'when the element provided is not present' do
it_behaves_like 'raising an exception warning the user to provide an history element'
it 'fails when the history element is not passed' do
expect { render_inline(described_class.new) }.to raise_error(ArgumentError, 'missing keyword: :element')
end

context 'when the element provided is not a history element' do
it_behaves_like 'raising an exception warning the user to provide an history element'
end
context 'with a HistoryElement::RequestAccepted' do
let(:element) { create(:history_element_request_accepted, user: user) }

it 'describes the element action' do
expect(render_inline(described_class.new(element: element))).to have_text('accepted request')
end

it 'displays the right icon' do
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-check')
end

context 'when the element provided is a history element superseded' do
it 'renders the element telling this request was superseded'
it 'renders the element comment'
it 'displays the element comment' do
expect(render_inline(described_class.new(element: element))).to have_text(element.comment)
end
end

context 'when the element provided is a history element accepted' do
it 'renders the element action'
it 'renders the element comment'
context 'with a HistoryElement::RequestSuperseded' do
let(:element) { create(:history_element_request_superseded, user: user) }

it 'describes the element action' do
expect(render_inline(described_class.new(element: element))).to have_text('superseded this request with')
end

it 'displays the right icon' do
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-code-commit')
end

it 'displays the element comment' do
expect(render_inline(described_class.new(element: element))).to have_text(element.comment)
end
end

context 'when the element provided is a history element about review added' do
context 'and review is known' do
it 'renders the element action'
it 'renders the element comment'
context 'with a HistoryElement::RequestReviewAdded' do
context 'with review' do
let(:element) { create(:history_element_request_review_added_with_review, user: user) }

it 'describes the element action' do
expect(render_inline(described_class.new(element: element))).to have_text('as a reviewer')
end

it 'displays the right icon' do
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-circle')
end

it 'displays the element comment' do
expect(render_inline(described_class.new(element: element))).to have_text(element.comment)
end
end

context 'and review is unknown' do
it 'renders the element action'
it 'renders the element comment'
context 'without review' do
let(:element) { create(:history_element_request_review_added_without_review, user: user, description_extension: nil) }

it 'describes the element action' do
expect(render_inline(described_class.new(element: element))).to have_text('added a reviewer')
end

it 'displays the right icon' do
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-circle')
end

it 'displays the element comment' do
expect(render_inline(described_class.new(element: element))).to have_text(element.comment)
end
end
end
# rubocop:enable RSpec/RepeatedExampleGroupBody
end

0 comments on commit 149603f

Please sign in to comment.