summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/tab_width_spec.rb
blob: f0efb6ec4a78abed5c36850b74e55febbf52a1cb (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
27
28
29
30
31
# frozen_string_literal: true

require 'fast_spec_helper'

RSpec.describe Gitlab::TabWidth, lib: true do
  describe '.css_class_for_user' do
    it 'returns default CSS class when user is nil' do
      css_class = described_class.css_class_for_user(nil)

      expect(css_class).to eq('tab-width-8')
    end

    it "returns CSS class for user's tab width", :aggregate_failures do
      [1, 6, 12].each do |i|
        user = double('user', tab_width: i)
        css_class = described_class.css_class_for_user(user)

        expect(css_class).to eq("tab-width-#{i}")
      end
    end

    it 'raises if tab width is out of valid range', :aggregate_failures do
      [0, 13, 'foo', nil].each do |i|
        expect do
          user = double('user', tab_width: i)
          described_class.css_class_for_user(user)
        end.to raise_error(ArgumentError)
      end
    end
  end
end