Sha256: 55be3d02d47288de07bac14401204f2994cce3629cbe75ec055765958cb3bf0f

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/models/stream'

module Vedeu
  describe Stream do
    it 'has a colour attribute' do
      Stream.new({ colour: { foreground: '#ff0000', background: '#000000' } }).colour.must_be_instance_of(Colour)
    end

    it 'has a text attribute' do
      Stream.new({ text: 'Some text' }).text.must_equal('Some text')
    end

    it 'has a style attribute' do
      Stream.new({ style: 'normal' }).style.must_equal("\e[24m\e[21m\e[27m")
    end

    describe '#to_s' do
      it 'returns a String' do
        Stream.new({
          style:  'normal',
          colour: { foreground: '#ff0000', background: '#000000' },
          text:   'Some text'
        }).to_s.must_equal("\e[38;5;196m\e[48;5;16m\e[24m\e[21m\e[27mSome text")
      end
    end

    describe '#to_json' do
      it 'returns a String' do
        Stream.new({
          style:  'normal',
          colour: { foreground: '#ff0000', background: '#000000' },
          text:   'Some text'
        }).to_json.must_equal("{\"colour\":{\"foreground\":\"\\u001b[38;5;196m\",\"background\":\"\\u001b[48;5;16m\"},\"style\":\"\\u001b[24m\\u001b[21m\\u001b[27m\",\"text\":\"Some text\"}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.0.31 test/lib/vedeu/models/stream_test.rb