Sha256: 03f3b6128110303e0165eb6f79fa26d2f2cf322ea071ab9f60af24101b0ddacc

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'test_helper'

module Vedeu
  module API

    describe Keymap do

      describe '#key' do
        before { Vedeu::Keymaps.reset }

        it 'raises an exception when a block is not given' do
          proc {
            Vedeu.keys do
              key 'q'
            end
          }.must_raise(InvalidSyntax)
        end

        it 'raises an exception when a key is not given' do
          proc {
            Vedeu.keys do
              key('') { :some_action }
            end
          }.must_raise(InvalidSyntax)
        end

        it 'returns the instance of API::Keymap' do
          Vedeu.keys do
            key('f') { :some_action }
          end.must_be_instance_of(API::Keymap)
        end

        it 'returns a collection of the keypresses' do
          Keymap.new.key('v', 'd', 'u') do
            :some_action
          end.must_equal(['v', 'd', 'u'])
        end
      end

      describe '#interface' do
        it 'returns the instance of API::Keymap' do
          Vedeu.keys do
            key('d') { :some_action }
            interface 'neodymium'
          end.must_be_instance_of(API::Keymap)
        end

        it 'returns the instance of API::Keymap' do
          Vedeu.keys do
            key('e') { :some_action }
            interface ['neodymium', 'californium']
          end.must_be_instance_of(API::Keymap)
        end

        it 'returns a collection of the interfaces' do
          Keymap.new.interface('americium').must_equal(['americium'])
        end
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vedeu-0.2.4 test/lib/vedeu/api/keymap_test.rb