diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-09-03 16:30:35 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-09-03 16:30:35 +0900 |
commit | 0f50dc848e58b47408713c2c31f2be73287c030a (patch) | |
tree | 6bf96117303bbde31fc71092302e185bdfb37429 /test/test_go.rb | |
parent | c5e4b83de3a201e496f356e826529a45165138ea (diff) |
Add 'GET /' endpoint for getting the program state (experimental)
Related #3372
Diffstat (limited to 'test/test_go.rb')
-rwxr-xr-x | test/test_go.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_go.rb b/test/test_go.rb index f85f7a23..c192835e 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -8,6 +8,7 @@ require 'shellwords' require 'erb' require 'tempfile' require 'net/http' +require 'json' TEMPLATE = DATA.read UNSETS = %w[ @@ -2776,9 +2777,21 @@ class TestGoFZF < TestBase -> { URI("http://localhost:#{File.read('/tmp/fzf-port').chomp}") } }.each do |opts, fn| tmux.send_keys "seq 10 | fzf #{opts}", :Enter tmux.until { |lines| assert_equal 10, lines.item_count } + state = JSON.parse(Net::HTTP.get(fn.call), symbolize_names: true) + assert_equal 10, state[:totalCount] + assert_equal 10, state[:matchCount] + assert_empty state[:query] + assert_equal({ index: 0, text: '1' }, state[:current]) + Net::HTTP.post(fn.call, 'change-query(yo)+reload(seq 100)+change-prompt:hundred> ') tmux.until { |lines| assert_equal 100, lines.item_count } tmux.until { |lines| assert_equal 'hundred> yo', lines[-1] } + state = JSON.parse(Net::HTTP.get(fn.call), symbolize_names: true) + assert_equal 100, state[:totalCount] + assert_equal 0, state[:matchCount] + assert_equal 'yo', state[:query] + assert_nil state[:current] + teardown setup end |