2016-07-28 09:30:05 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-19 07:08:47 -04:00
|
|
|
describe Gitlab::Badge::Pipeline::Template do
|
|
|
|
let(:badge) { double(entity: 'pipeline', status: 'success') }
|
2016-08-11 05:16:14 -04:00
|
|
|
let(:template) { described_class.new(badge) }
|
2016-07-28 09:30:05 -04:00
|
|
|
|
|
|
|
describe '#key_text' do
|
2017-07-19 07:08:47 -04:00
|
|
|
it 'is always says pipeline' do
|
|
|
|
expect(template.key_text).to eq 'pipeline'
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#value_text' do
|
|
|
|
it 'is status value' do
|
2017-07-19 07:31:47 -04:00
|
|
|
expect(template.value_text).to eq 'passed'
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'widths and text anchors' do
|
|
|
|
it 'has fixed width and text anchors' do
|
2017-07-19 07:08:47 -04:00
|
|
|
expect(template.width).to eq 116
|
|
|
|
expect(template.key_width).to eq 62
|
2016-07-28 09:30:05 -04:00
|
|
|
expect(template.value_width).to eq 54
|
2017-07-19 07:08:47 -04:00
|
|
|
expect(template.key_text_anchor).to eq 31
|
|
|
|
expect(template.value_text_anchor).to eq 89
|
2016-07-28 09:30:05 -04:00
|
|
|
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
|
2016-08-11 05:16:14 -04:00
|
|
|
before do
|
|
|
|
allow(badge).to receive(:status).and_return('failed')
|
|
|
|
end
|
2016-07-28 09:30:05 -04:00
|
|
|
|
|
|
|
it 'has expected color' do
|
|
|
|
expect(template.value_color).to eq '#e05d44'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when status is running' do
|
2016-08-11 05:16:14 -04:00
|
|
|
before do
|
|
|
|
allow(badge).to receive(:status).and_return('running')
|
|
|
|
end
|
2016-07-28 09:30:05 -04:00
|
|
|
|
|
|
|
it 'has expected color' do
|
|
|
|
expect(template.value_color).to eq '#dfb317'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when status is unknown' do
|
2016-08-11 05:16:14 -04:00
|
|
|
before do
|
|
|
|
allow(badge).to receive(:status).and_return('unknown')
|
|
|
|
end
|
2016-07-28 09:30:05 -04:00
|
|
|
|
|
|
|
it 'has expected color' do
|
|
|
|
expect(template.value_color).to eq '#9f9f9f'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when status does not match any known statuses' do
|
2016-08-11 05:16:14 -04:00
|
|
|
before do
|
|
|
|
allow(badge).to receive(:status).and_return('invalid')
|
|
|
|
end
|
2016-07-28 09:30:05 -04:00
|
|
|
|
|
|
|
it 'has expected color' do
|
|
|
|
expect(template.value_color).to eq '#9f9f9f'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|