Sha256: 9b5e96b7650e00498099f5de433e552c0437059d2c49143dbe6d5e3e54ff514c

Contents?: true

Size: 1.92 KB

Versions: 6

Compression:

Stored size: 1.92 KB

Contents

require 'test_helper'

module Vedeu

  module Input

    describe Mouse do

      let(:described) { Vedeu::Input::Mouse }
      let(:instance)  { described.new(input) }
      let(:input)     {}

      describe '#initialize' do
        it { instance.must_be_instance_of(described) }
        it { instance.instance_variable_get('@input').must_equal(input) }
      end

      describe '.click' do
        before { Vedeu.interface(:mouse_test) {} }
        after  { Vedeu.interfaces.reset! }

        subject { described.click(input) }

        context 'when the left mouse button was pressed' do
          let(:input) { "\e[M ,%" }

          it do
            Vedeu.expects(:trigger).with(:_mouse_event_, input)
            Vedeu.expects(:trigger).
              with(:_cursor_reposition_, Vedeu.focus, 5, 12)
            subject
          end
        end

        context 'when the mouse scroll wheel was moved upwards' do
          let(:input) { "\e[M`6E" }

          it do
            Vedeu.expects(:trigger).with(:_mouse_event_, input)
            Vedeu.expects(:trigger).with(:_cursor_up_, Vedeu.focus)
            subject
          end
        end

        context 'when the mouse scroll wheel was moved downwards' do
          let(:input) { "\e[MaN5" }

          it do
            Vedeu.expects(:trigger).with(:_mouse_event_, input)
            Vedeu.expects(:trigger).with(:_cursor_down_, Vedeu.focus)
            subject
          end
        end

        context 'when the mouse input was not recognised' do
          let(:input) { "\e[Mb0(" }

          it do
            Vedeu.expects(:trigger).with(:_mouse_event_, input)
            subject.
              must_equal("\e[93m[input]    \e[39m\e[33mVedeu does not " \
                         "support mouse button '66' yet.\e[39m")
          end
        end
      end

      describe '#click' do
        it { instance.must_respond_to(:click) }
      end

    end # Mouse

  end # Input

end # Vedeu

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vedeu-0.8.0 test/lib/vedeu/input/mouse_test.rb
vedeu-0.7.4 test/lib/vedeu/input/mouse_test.rb
vedeu-0.7.3 test/lib/vedeu/input/mouse_test.rb
vedeu-0.7.2 test/lib/vedeu/input/mouse_test.rb
vedeu-0.7.1 test/lib/vedeu/input/mouse_test.rb
vedeu-0.7.0 test/lib/vedeu/input/mouse_test.rb