diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/lib/sidebars/menu_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/lib/sidebars/menu_spec.rb')
-rw-r--r-- | spec/lib/sidebars/menu_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/lib/sidebars/menu_spec.rb b/spec/lib/sidebars/menu_spec.rb index 7dcf1940442..95009aa063f 100644 --- a/spec/lib/sidebars/menu_spec.rb +++ b/spec/lib/sidebars/menu_spec.rb @@ -144,4 +144,50 @@ RSpec.describe Sidebars::Menu do end end end + + describe '#container_html_options' do + before do + allow(menu).to receive(:title).and_return('Foo Menu') + end + + context 'when menu can be rendered' do + before do + allow(menu).to receive(:render?).and_return(true) + end + + context 'when menu has renderable items' do + before do + menu.add_item(Sidebars::MenuItem.new(title: 'foo1', link: 'foo1', active_routes: { path: 'bar' })) + end + + it 'contains the special class' do + expect(menu.container_html_options[:class]).to eq 'has-sub-items' + end + + context 'when menu already has other classes' do + it 'appends special class' do + allow(menu).to receive(:extra_container_html_options).and_return(class: 'foo') + + expect(menu.container_html_options[:class]).to eq 'foo has-sub-items' + end + end + end + + context 'when menu does not have renderable items' do + it 'does not contain the special class' do + expect(menu.container_html_options[:class]).to be_nil + end + end + end + + context 'when menu cannot be rendered' do + before do + allow(menu).to receive(:render?).and_return(false) + end + + it 'does not contain special class' do + expect(menu.container_html_options[:class]).to be_nil + end + end + end end |