Sha256: 3742b600e6e91c4fb9c6b9dd319e9c25ed4acf7b08d3ca200ec3bcc09b0aa973

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'test_helper'

module Vedeu

  describe Clear do

    before do
      Interfaces.reset
      Terminal.console.stubs(:print)
    end

    describe '#initialize' do
      it 'returns an instance of itself' do
        interface = mock('Interface')
        Clear.new(interface).must_be_instance_of(Clear)
      end
    end

    describe '.call' do
      it 'returns the escape sequence to clear the whole interface' do
        interface = Interface.new({
          name:   'Clear.call',
          geometry: {
            width:  5,
            height: 2
          }
        })
        Clear.call(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.call',
          geometry: {
            width:  5,
            height: 2,
          },
          colour: {
            foreground: '#00ff00',
            background: '#ffff00'
          }
        })
        Clear.call(interface).must_equal([
          "\e[38;2;0;255;0m\e[48;2;255;255;0m" \
          "\e[1;1H     \e[1;1H" \
          "\e[2;1H     \e[2;1H"
        ])
      end
    end

  end # Clear

end # Vedeu

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vedeu-0.2.10 test/lib/vedeu/output/clear_test.rb
vedeu-0.2.9 test/lib/vedeu/output/clear_test.rb