2017-02-28 19:14:16 +01:00
|
|
|
describe 'a wrapped widget' do
|
|
|
|
let(:widget) { 'backward-delete-char' }
|
|
|
|
|
2019-01-12 03:02:55 +01:00
|
|
|
let(:initialize_widget) do
|
|
|
|
-> do
|
|
|
|
session.run_command(<<~ZSH)
|
|
|
|
if [[ "$widgets[#{widget}]" == "builtin" ]]; then
|
|
|
|
_orig_#{widget}() { zle .#{widget} }
|
|
|
|
zle -N orig-#{widget} _orig_#{widget}
|
|
|
|
else
|
|
|
|
zle -N orig-#{widget} ${widgets[#{widget}]#*:}
|
|
|
|
fi
|
|
|
|
|
|
|
|
#{widget}-magic() { zle orig-#{widget}; BUFFER+=b }
|
|
|
|
zle -N #{widget} #{widget}-magic
|
|
|
|
ZSH
|
2017-02-28 19:14:16 +01:00
|
|
|
end
|
2019-01-12 03:02:55 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'initialized before sourcing the plugin' do
|
|
|
|
let(:before_sourcing) { initialize_widget }
|
2017-02-28 19:14:16 +01:00
|
|
|
|
|
|
|
it 'executes the custom behavior and the built-in behavior' do
|
|
|
|
with_history('foobar', 'foodar') do
|
|
|
|
session.send_string('food').send_keys('C-h')
|
|
|
|
wait_for { session.content }.to eq('foobar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'initialized after sourcing the plugin' do
|
2019-01-12 03:02:55 +01:00
|
|
|
let(:after_sourcing) { initialize_widget }
|
2017-02-28 19:14:16 +01:00
|
|
|
|
|
|
|
it 'executes the custom behavior and the built-in behavior' do
|
|
|
|
with_history('foobar', 'foodar') do
|
|
|
|
session.send_string('food').send_keys('C-h')
|
|
|
|
wait_for { session.content }.to eq('foobar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|