blob: a7e21fb8bb1dd84e6cd10490948705c17f989a4e (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
require 'spec_helper'
describe Gitlab::Badge::Build::Template do
let(:badge) { double(entity: 'build', status: 'success') }
let(:template) { described_class.new(badge) }
describe '#key_text' do
it 'is always says build' do
expect(template.key_text).to eq 'build'
end
end
describe '#value_text' do
it 'is status value' do
expect(template.value_text).to eq 'success'
end
end
describe 'widths and text anchors' do
it 'has fixed width and text anchors' do
expect(template.width).to eq 92
expect(template.key_width).to eq 38
expect(template.value_width).to eq 54
expect(template.key_text_anchor).to eq 19
expect(template.value_text_anchor).to eq 65
end
end
describe '#key_color' do
it 'is always the same' do
expect(template.key_color).to eq '#555'
end
end
describe '#value_color' do
context 'when status is success' do
it 'has expected color' do
expect(template.value_color).to eq '#4c1'
end
end
context 'when status is failed' do
before do
allow(badge).to receive(:status).and_return('failed')
end
it 'has expected color' do
expect(template.value_color).to eq '#e05d44'
end
end
context 'when status is running' do
before do
allow(badge).to receive(:status).and_return('running')
end
it 'has expected color' do
expect(template.value_color).to eq '#dfb317'
end
end
context 'when status is unknown' do
before do
allow(badge).to receive(:status).and_return('unknown')
end
it 'has expected color' do
expect(template.value_color).to eq '#9f9f9f'
end
end
context 'when status does not match any known statuses' do
before do
allow(badge).to receive(:status).and_return('invalid')
end
it 'has expected color' do
expect(template.value_color).to eq '#9f9f9f'
end
end
end
end
|