Sha256: cc020d967848e4e0df081e1b9d580346d1f16ad1adf71f0d82b6a41d0f4406c9

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

require 'test_helper'
require 'vedeu/support/translator'

module Vedeu
  describe Translator do
    describe '#translate' do
      {
        '#ff0000' => 196, # red
        '#00ff00' => 46,  # green
        '#0000ff' => 21,  # blue
        '#ffffff' => 231, # white
        '#aadd00' => 148, # lime green
        '#b94f1c' => 130, # sunset orange
      }.map do |html_colour, terminal_colour|
        it 'translation is performed' do
          Translator.translate(html_colour)
            .must_equal(terminal_colour)
        end
      end

      it 'returns empty string when not present' do
        Translator.translate.must_equal('')
      end

      it 'returns empty string when the wrong type!' do
        Translator.translate(:wrong_type).must_equal('')
      end

      it 'returns empty string when invalid format' do
        Translator.translate('345678').must_equal('')
      end

      it 'returns empty string when invalid format' do
        Translator.translate('#h11111').must_equal('')
      end

      it 'returns empty string when invalid format' do
        Translator.translate('#1111').must_equal('')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vedeu-0.1.3 test/lib/vedeu/support/translator_test.rb
vedeu-0.1.2 test/lib/vedeu/support/translator_test.rb
vedeu-0.1.1 test/lib/vedeu/support/translator_test.rb
vedeu-0.1.0 test/lib/vedeu/support/translator_test.rb
vedeu-0.0.42 test/lib/vedeu/support/translator_test.rb
vedeu-0.0.41 test/lib/vedeu/support/translator_test.rb
vedeu-0.0.40 test/lib/vedeu/support/translator_test.rb