summaryrefslogtreecommitdiff
path: root/spec/frontend/fixtures/tabs.rb
blob: 697ff1c7c20572ae6c48fd38a41bfa8e3a09a8d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'GlTabsBehavior', '(JavaScript fixtures)', type: :helper do
  include JavaScriptFixturesHelpers
  include TabHelper

  let(:response) { @tabs }

  it 'tabs/tabs.html' do
    tabs = gl_tabs_nav({ data: { testid: 'tabs' } }) do
      gl_tab_link_to('Foo', '#foo', item_active: true, data: { testid: 'foo-tab' }) +
      gl_tab_link_to('Bar', '#bar', item_active: false, data: { testid: 'bar-tab' }) +
      gl_tab_link_to('Qux', '#qux', item_active: false, data: { testid: 'qux-tab' })
    end

    panels = content_tag(:div, class: 'tab-content') do
      content_tag(:div, 'Foo', { id: 'foo', class: 'tab-pane active', data: { testid: 'foo-panel' } }) +
      content_tag(:div, 'Bar', { id: 'bar', class: 'tab-pane', data: { testid: 'bar-panel' } }) +
      content_tag(:div, 'Qux', { id: 'qux', class: 'tab-pane', data: { testid: 'qux-panel' } })
    end

    @tabs = tabs + panels
  end
end