Sha256: dc33e46396463eb1e2b09fd55c6f9bd5e017cf4c8fb5c51db94a67e8a40963f4

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require_relative '../../../test_helper'
require_relative '../../../../lib/vedeu/repository/interface_repository'
require_relative '../../../../lib/vedeu/output/interface_renderer'
require_relative '../../../../lib/vedeu/models/interface'

module Vedeu
  describe InterfaceRenderer do
    before { InterfaceRepository.reset }

    describe '.clear' do
      it 'returns the escape sequence to clear the whole interface' do
        interface = Interface.new({
          name:   '.clear',
          width:  5,
          height: 2
        })
        InterfaceRenderer.clear(interface).must_equal(
          "\e[1;1H     \e[1;1H" \
          "\e[2;1H     \e[2;1H"
        )
      end

      it 'returns the escape sequence to clear the whole interface with specified colours' do
        interface = Interface.new({
          name:   '.clear',
          width:  5,
          height: 2,
          colour: {
            foreground: '#00ff00',
            background: '#ffff00'
          }
        })
        InterfaceRenderer.clear(interface).must_equal(
          "\e[38;5;46m\e[48;5;226m" \
          "\e[1;1H     \e[1;1H" \
          "\e[2;1H     \e[2;1H"
        )
      end
    end

    describe '.render' do
      it 'returns the content for the interface' do
        interface = Interface.new({
          name:   '.render',
          width:  5,
          height: 2,
          lines:  'InterfaceRenderer.render'
        })
        InterfaceRenderer.render(interface).must_equal("\e[1;1HInterfaceRenderer.render")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vedeu-0.0.36 test/lib/vedeu/output/interface_renderer_test.rb
vedeu-0.0.35 test/lib/vedeu/output/interface_renderer_test.rb
vedeu-0.0.33 test/lib/vedeu/output/interface_renderer_test.rb