diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-23 09:10:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-23 09:10:24 +0300 |
commit | 17569e185c449d7b0fd6246b53b348afb9e61ca4 (patch) | |
tree | cad5654a801bda71085bc70ecfa00dfb0eb9322e /spec/components | |
parent | 8c1c323ac04b24b1167540893af699928ce8c156 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/components')
-rw-r--r-- | spec/components/pajamas/progress_component_spec.rb | 36 | ||||
-rw-r--r-- | spec/components/previews/pajamas/progress_component_preview.rb | 16 |
2 files changed, 52 insertions, 0 deletions
diff --git a/spec/components/pajamas/progress_component_spec.rb b/spec/components/pajamas/progress_component_spec.rb new file mode 100644 index 00000000000..5172f459a84 --- /dev/null +++ b/spec/components/pajamas/progress_component_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Pajamas::ProgressComponent, type: :component do + before do + render_inline(described_class.new(value: value, variant: variant)) + end + + let(:value) { 33 } + let(:variant) { nil } + + describe "value" do + it "sets the width of the progressbar" do + expect(page).to have_css ".progress-bar[style='width: #{value}%;']" + end + end + + describe "variant" do + where(:variant) { [:primary, :success] } + + with_them do + it "adds variant class" do + expect(page).to have_css ".progress-bar.bg-#{variant}" + end + end + + context "with unknown variant" do + let(:variant) { :nope } + + it "adds the default variant class" do + expect(page).to have_css ".progress-bar.bg-primary" + end + end + end +end diff --git a/spec/components/previews/pajamas/progress_component_preview.rb b/spec/components/previews/pajamas/progress_component_preview.rb new file mode 100644 index 00000000000..4de07872a80 --- /dev/null +++ b/spec/components/previews/pajamas/progress_component_preview.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Pajamas + class ProgressComponentPreview < ViewComponent::Preview + # Progress + # --- + # + # See its design reference [here](https://design.gitlab.com/components/progress-bar). + # + # @param value number + # @param variant select [primary, success] + def default(value: 50, variant: :primary) + render Pajamas::ProgressComponent.new(value: value, variant: variant) + end + end +end |