Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-27 15:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-27 15:08:19 +0300
commit863ba7d77355b305b06112b0c6c3cab3c09898b0 (patch)
tree6b657c3bfc0cff804fad6094ba61d42c6925c4d4 /spec/components/pajamas
parent359bc6940b1205035e14f028b75d0c9c80a1fd5e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/components/pajamas')
-rw-r--r--spec/components/pajamas/alert_component_spec.rb82
1 files changed, 55 insertions, 27 deletions
diff --git a/spec/components/pajamas/alert_component_spec.rb b/spec/components/pajamas/alert_component_spec.rb
index 628d715ff64..58c1cb2231a 100644
--- a/spec/components/pajamas/alert_component_spec.rb
+++ b/spec/components/pajamas/alert_component_spec.rb
@@ -25,47 +25,71 @@ RSpec.describe Pajamas::AlertComponent, :aggregate_failures, type: :component do
it 'renders the default variant' do
expect(rendered_component).to have_selector('.gl-alert-info')
expect(rendered_component).to have_selector("[data-testid='information-o-icon']")
+ expect(rendered_component).not_to have_selector('.gl-alert-no-icon')
end
it 'renders a dismiss button' do
expect(rendered_component).to have_selector('.gl-dismiss-btn.js-close')
expect(rendered_component).to have_selector("[data-testid='close-icon']")
+ expect(rendered_component).not_to have_selector('.gl-alert-not-dismissible')
end
end
context 'with custom options' do
context 'with simple options' do
- context 'without dismissible content' do
- before do
- render_inline described_class.new(
- title: '_title_',
- dismissible: false,
- alert_class: '_alert_class_',
- alert_data: {
- feature_id: '_feature_id_',
- dismiss_endpoint: '_dismiss_endpoint_'
- }
- )
- end
+ before do
+ render_inline described_class.new(
+ title: '_title_',
+ alert_class: '_alert_class_',
+ alert_data: {
+ feature_id: '_feature_id_',
+ dismiss_endpoint: '_dismiss_endpoint_'
+ }
+ )
+ end
- it 'sets the title' do
- expect(rendered_component).to have_selector('.gl-alert-title')
- expect(rendered_component).to have_content('_title_')
- expect(rendered_component).not_to have_selector('.gl-alert-icon-no-title')
- end
+ it 'sets the title' do
+ expect(rendered_component).to have_selector('.gl-alert-title')
+ expect(rendered_component).to have_content('_title_')
+ expect(rendered_component).not_to have_selector('.gl-alert-icon-no-title')
+ end
- it 'sets to not be dismissible' do
- expect(rendered_component).not_to have_selector('.gl-dismiss-btn.js-close')
- expect(rendered_component).not_to have_selector("[data-testid='close-icon']")
- end
+ it 'sets the alert_class' do
+ expect(rendered_component).to have_selector('._alert_class_')
+ end
- it 'sets the alert_class' do
- expect(rendered_component).to have_selector('._alert_class_')
- end
+ it 'sets the alert_data' do
+ expect(rendered_component).to have_selector('[data-feature-id="_feature_id_"][data-dismiss-endpoint="_dismiss_endpoint_"]')
+ end
+ end
- it 'sets the alert_data' do
- expect(rendered_component).to have_selector('[data-feature-id="_feature_id_"][data-dismiss-endpoint="_dismiss_endpoint_"]')
- end
+ context 'with dismissible disabled' do
+ before do
+ render_inline described_class.new(dismissible: false)
+ end
+
+ it 'has the "not dismissible" class' do
+ expect(rendered_component).to have_selector('.gl-alert-not-dismissible')
+ end
+
+ it 'does not render the dismiss button' do
+ expect(rendered_component).not_to have_selector('.gl-dismiss-btn.js-close')
+ expect(rendered_component).not_to have_selector("[data-testid='close-icon']")
+ end
+ end
+
+ context 'with the icon hidden' do
+ before do
+ render_inline described_class.new(show_icon: false)
+ end
+
+ it 'has the hidden icon class' do
+ expect(rendered_component).to have_selector('.gl-alert-no-icon')
+ end
+
+ it 'does not render the icon' do
+ expect(rendered_component).not_to have_selector('.gl-alert-icon')
+ expect(rendered_component).not_to have_selector("[data-testid='information-o-icon']")
end
end
@@ -79,6 +103,10 @@ RSpec.describe Pajamas::AlertComponent, :aggregate_failures, type: :component do
)
end
+ it 'does not have "not dismissible" class' do
+ expect(rendered_component).not_to have_selector('.gl-alert-not-dismissible')
+ end
+
it 'renders a dismiss button and data' do
expect(rendered_component).to have_selector('.gl-dismiss-btn.js-close._close_button_class_')
expect(rendered_component).to have_selector("[data-testid='close-icon']")