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:
Diffstat (limited to 'spec/helpers/tab_helper_spec.rb')
-rw-r--r--spec/helpers/tab_helper_spec.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb
index bd8a8fa174a..346bfc7850c 100644
--- a/spec/helpers/tab_helper_spec.rb
+++ b/spec/helpers/tab_helper_spec.rb
@@ -5,6 +5,60 @@ require 'spec_helper'
RSpec.describe TabHelper do
include ApplicationHelper
+ describe 'gl_tabs_nav' do
+ it 'creates a tabs navigation' do
+ expect(gl_tabs_nav).to match(%r{<ul class=".*" role="tablist"><\/ul>})
+ end
+
+ it 'captures block output' do
+ expect(gl_tabs_nav { "block content" }).to match(/block content/)
+ end
+
+ it 'adds styles classes' do
+ expect(gl_tabs_nav).to match(/class="nav gl-tabs-nav"/)
+ end
+
+ it 'adds custom class' do
+ expect(gl_tabs_nav(class: 'my-class' )).to match(/class=".*my-class.*"/)
+ end
+ end
+
+ describe 'gl_tab_link_to' do
+ before do
+ allow(self).to receive(:current_page?).and_return(false)
+ end
+
+ it 'creates a tab' do
+ expect(gl_tab_link_to('Link', '/url')).to eq('<li class="nav-item" role="presentation"><a class="nav-link gl-tab-nav-item" href="/url">Link</a></li>')
+ end
+
+ it 'creates a tab with block output' do
+ expect(gl_tab_link_to('/url') { 'block content' }).to match(/block content/)
+ end
+
+ it 'creates a tab with custom classes' do
+ expect(gl_tab_link_to('Link', '/url', { class: 'my-class' })).to match(/<a class=".*my-class.*"/)
+ end
+
+ it 'creates an active tab with item_active = true' do
+ expect(gl_tab_link_to('Link', '/url', { item_active: true })).to match(/<a class=".*active gl-tab-nav-item-active gl-tab-nav-item-active-indigo.*"/)
+ end
+
+ context 'when on the active page' do
+ before do
+ allow(self).to receive(:current_page?).and_return(true)
+ end
+
+ it 'creates an active tab' do
+ expect(gl_tab_link_to('Link', '/url')).to match(/<a class=".*active gl-tab-nav-item-active gl-tab-nav-item-active-indigo.*"/)
+ end
+
+ it 'creates an inactive tab with item_active = false' do
+ expect(gl_tab_link_to('Link', '/url', { item_active: false })).not_to match(/<a class=".*active.*"/)
+ end
+ end
+ end
+
describe 'nav_link' do
using RSpec::Parameterized::TableSyntax