test/lib/vedeu/presentation/background_test.rb in vedeu-0.3.4 vs test/lib/vedeu/presentation/background_test.rb in vedeu-0.3.5

- old
+ new

@@ -2,10 +2,14 @@ module Vedeu describe Background do + let(:described) { Vedeu::Background } + let(:instance) { described.new(colour) } + let(:colour) {} + describe '.escape_sequence' do describe 'when the colour is empty' do it 'returns an empty String' do Background.escape_sequence('').must_equal('') end @@ -14,11 +18,11 @@ describe 'when the colour is named (3-bit / 8 colours)' do { red: "\e[41m", yellow: "\e[43m", magenta: "\e[45m", - white: "\e[47m", + white: "\e[107m", default: "\e[49m", unknown: '', }.map do |colour, result| it "returns the correct escape sequence for #{colour}" do Background.escape_sequence(colour).must_equal(result) @@ -76,9 +80,45 @@ '#h11111' => '', }.map do |colour, result| it "returns the correct escape sequence for #{colour}" do Background.escape_sequence(colour).must_equal(result) end + end + end + end + + describe '.to_html' do + subject { instance.to_html } + + context 'when the colour is empty' do + let(:colour) {} + + it 'returns an empty String' do + subject.must_equal('') + end + end + + context 'when the colour is named (3-bit / 8 colours)' do + let(:colour) { :red } + + it 'returns an empty String' do + subject.must_equal('') + end + end + + context 'when the colour is numbered (8-bit / 256 colours)' do + let(:colour) { 118 } + + it 'returns an empty String' do + subject.must_equal('') + end + end + + context 'when the colour is a CSS value' do + let(:colour) { '#afd700' } + + it 'returns the colour as a CSS value' do + subject.must_equal('#afd700') end end end end # Background