2017-03-04 02:59:30 +08:00
|
|
|
describe 'the `autosuggest-enable` widget' do
|
|
|
|
before do
|
|
|
|
session.
|
|
|
|
run_command('typeset -g _ZSH_AUTOSUGGEST_DISABLED').
|
|
|
|
run_command('bindkey ^B autosuggest-enable')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'enables suggestions and fetches a suggestion' do
|
2017-03-05 06:04:04 +08:00
|
|
|
with_history('echo hello') do
|
|
|
|
session.send_string('e')
|
2017-03-04 02:59:30 +08:00
|
|
|
sleep 1
|
2017-03-05 06:04:04 +08:00
|
|
|
expect(session.content).to eq('e')
|
2017-03-04 02:59:30 +08:00
|
|
|
|
|
|
|
session.send_keys('C-b')
|
2017-03-05 06:04:04 +08:00
|
|
|
session.send_string('c')
|
2017-03-04 02:59:30 +08:00
|
|
|
wait_for { session.content }.to eq('echo hello')
|
2017-03-05 06:04:04 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'invoked on an empty buffer' do
|
|
|
|
it 'does not fetch a suggestion' do
|
|
|
|
with_history('echo hello') do
|
|
|
|
session.send_keys('C-b')
|
|
|
|
sleep 1
|
|
|
|
expect(session.content).to eq('')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'invoked on a non-empty buffer' do
|
|
|
|
it 'fetches a suggestion' do
|
|
|
|
with_history('echo hello') do
|
|
|
|
session.send_string('e')
|
|
|
|
sleep 1
|
|
|
|
expect(session.content).to eq('e')
|
2017-03-04 02:59:30 +08:00
|
|
|
|
2017-03-05 06:04:04 +08:00
|
|
|
session.send_keys('C-b')
|
|
|
|
wait_for { session.content }.to eq('echo hello')
|
|
|
|
end
|
2017-03-04 02:59:30 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|