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

color_schemes_spec.rb « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: feb5648ff2d5870a49e34a32c918dfa2fddcb805 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::ColorSchemes do
  describe '.body_classes' do
    it 'returns a space-separated list of class names' do
      css = described_class.body_classes

      expect(css).to include('white')
      expect(css).to include(' solarized-light ')
      expect(css).to include(' monokai')
    end
  end

  describe '.by_id' do
    it 'returns a scheme by its ID' do
      expect(described_class.by_id(1).name).to eq 'Light'
      expect(described_class.by_id(4).name).to eq 'Solarized Dark'
    end
  end

  describe '.default' do
    it 'returns the default scheme' do
      expect(described_class.default.id).to eq 1
    end
  end

  describe '.each' do
    it 'passes the block to the SCHEMES Array' do
      ids = []
      described_class.each { |scheme| ids << scheme.id }
      expect(ids).not_to be_empty
    end
  end

  describe '.for_user' do
    it 'returns default when user is nil' do
      expect(described_class.for_user(nil).id).to eq 1
    end

    it "returns user's preferred color scheme" do
      user = double(color_scheme_id: 5)
      expect(described_class.for_user(user).id).to eq 5
    end
  end
end