diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-18 00:22:15 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2022-12-21 01:35:08 +0900 |
commit | 1ba7484d606bf3797b3936651051bb4113dbcad2 (patch) | |
tree | e4452678c4991f113d6178d8f4f215dbecbe52af /src/options_test.go | |
parent | 51c518da1e981dddda18e55272be482e972d6861 (diff) |
Add --listen=HTTP_PORT option to receive actions
Supersedes #2019
See also:
* #1728
* https://github.com/junegunn/fzf.vim/pull/1044
Diffstat (limited to 'src/options_test.go')
-rw-r--r-- | src/options_test.go | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/options_test.go b/src/options_test.go index 0fb569fe..14ede09b 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -262,13 +262,17 @@ func TestBind(t *testing.T) { } } check(tui.CtrlA.AsEvent(), "", actBeginningOfLine) + errorString := "" + errorFn := func(e string) { + errorString = e + } parseKeymap(keymap, "ctrl-a:kill-line,ctrl-b:toggle-sort+up+down,c:page-up,alt-z:page-down,"+ "f1:execute(ls {+})+abort+execute(echo {+})+select-all,f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute;less {};,"+ "alt-a:execute-Multi@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};,"+ "x:Execute(foo+bar),X:execute/bar+baz/"+ ",f1:+first,f1:+top"+ - ",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up") + ",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up", errorFn) check(tui.CtrlA.AsEvent(), "", actKillLine) check(tui.CtrlB.AsEvent(), "", actToggleSort, actUp, actDown) check(tui.Key('c'), "", actPageUp) @@ -286,12 +290,15 @@ func TestBind(t *testing.T) { check(tui.Key('+'), "++\nfoobar,Y:execute(baz)+up", actExecute) for idx, char := range []rune{'~', '!', '@', '#', '$', '%', '^', '&', '*', '|', ';', '/'} { - parseKeymap(keymap, fmt.Sprintf("%d:execute%cfoobar%c", idx%10, char, char)) + parseKeymap(keymap, fmt.Sprintf("%d:execute%cfoobar%c", idx%10, char, char), errorFn) check(tui.Key([]rune(fmt.Sprintf("%d", idx%10))[0]), "foobar", actExecute) } - parseKeymap(keymap, "f1:abort") + parseKeymap(keymap, "f1:abort", errorFn) check(tui.F1.AsEvent(), "", actAbort) + if len(errorString) > 0 { + t.Errorf("error parsing keymap: %s", errorString) + } } func TestColorSpec(t *testing.T) { @@ -466,3 +473,19 @@ func TestValidateSign(t *testing.T) { } } } + +func TestParseSingleActionList(t *testing.T) { + actions := parseSingleActionList("Execute@foo+bar,baz@+up+up+reload:down+down", func(string) {}) + if len(actions) != 4 { + t.Errorf("Invalid number of actions parsed:%d", len(actions)) + } + if actions[0].t != actExecute || actions[0].a != "foo+bar,baz" { + t.Errorf("Invalid action parsed: %v", actions[0]) + } + if actions[1].t != actUp || actions[2].t != actUp { + t.Errorf("Invalid action parsed: %v / %v", actions[1], actions[2]) + } + if actions[3].t != actReload || actions[3].a != "down+down" { + t.Errorf("Invalid action parsed: %v", actions[3]) + } +} |