Implement `quit' action keyword
This commit is contained in:
23
spec/uh/wm/actions_handler_spec.rb
Normal file
23
spec/uh/wm/actions_handler_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
module Uh
|
||||
module WM
|
||||
RSpec.describe ActionsHandler do
|
||||
let(:env) { Env.new(StringIO.new) }
|
||||
let(:events) { Dispatcher.new }
|
||||
subject(:actions) { described_class.new env, events }
|
||||
|
||||
describe '#evaluate' do
|
||||
it 'evaluates given code' do
|
||||
expect { actions.evaluate proc { throw :action_code } }
|
||||
.to throw_symbol :action_code
|
||||
end
|
||||
end
|
||||
|
||||
describe '#quit' do
|
||||
it 'emits the quit event' do
|
||||
expect(events).to receive(:emit).with :quit
|
||||
actions.quit
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -21,6 +21,10 @@ module Uh
|
||||
expect(env.layout_class).not_to be
|
||||
end
|
||||
|
||||
it 'has defaults key bindings set' do
|
||||
expect(env.keybinds.keys).to eq %i[q]
|
||||
end
|
||||
|
||||
describe '#verbose?' do
|
||||
context 'when verbose mode is disabled' do
|
||||
before { env.verbose = false }
|
||||
|
@@ -63,6 +63,12 @@ module Uh
|
||||
end
|
||||
|
||||
describe '#register_event_hooks' do
|
||||
it 'registers quit event hook' do
|
||||
runner.register_event_hooks
|
||||
expect(runner).to receive(:stop!)
|
||||
runner.events.emit :quit
|
||||
end
|
||||
|
||||
it 'registers manager event hooks for logging' do
|
||||
runner.register_event_hooks
|
||||
expect(env).to receive(:log)
|
||||
@@ -86,6 +92,13 @@ module Uh
|
||||
runner.register_event_hooks
|
||||
expect(runner.events[:key, :f, :shift]).not_to be_empty
|
||||
end
|
||||
|
||||
it 'registers key bindings code evaluation with the actions handler' do
|
||||
env.keybinds[:f] = code = proc { }
|
||||
runner.register_event_hooks
|
||||
expect(runner.actions).to receive(:evaluate).with code
|
||||
runner.events.emit :key, :f
|
||||
end
|
||||
end
|
||||
|
||||
describe '#connect_manager' do
|
||||
|
Reference in New Issue
Block a user