github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/edit/instant_test.go (about) 1 package edit 2 3 import ( 4 "testing" 5 6 "github.com/markusbkk/elvish/pkg/cli/term" 7 "github.com/markusbkk/elvish/pkg/cli/tk" 8 ) 9 10 func TestInstantAddon_ValueOutput(t *testing.T) { 11 f := setup(t) 12 13 evals(f.Evaler, "edit:-instant:start") 14 f.TestTTY(t, 15 "~> ", term.DotHere, "\n", 16 " INSTANT \n", Styles, 17 "*********", 18 ) 19 20 feedInput(f.TTYCtrl, "+") 21 f.TestTTY(t, 22 "~> +", Styles, 23 " v", term.DotHere, "\n", 24 " INSTANT \n", Styles, 25 "*********", 26 "▶ 0", 27 ) 28 29 feedInput(f.TTYCtrl, " 1 2") 30 f.TestTTY(t, 31 "~> + 1 2", Styles, 32 " v ", term.DotHere, "\n", 33 " INSTANT \n", Styles, 34 "*********", 35 "▶ 3", 36 ) 37 } 38 39 func TestInstantAddon_ByteOutput(t *testing.T) { 40 f := setup(t) 41 42 // We don't want to trigger the evaluation of "e", "ec", and "ech", so we 43 // start with a non-empty code buffer. 44 f.SetCodeBuffer(tk.CodeBuffer{Content: "echo ", Dot: 5}) 45 evals(f.Evaler, "edit:-instant:start") 46 f.TestTTY(t, 47 "~> echo ", Styles, 48 " vvvv ", term.DotHere, "\n", 49 " INSTANT \n", Styles, 50 "*********", 51 ) 52 53 feedInput(f.TTYCtrl, "hello") 54 f.TestTTY(t, 55 "~> echo hello", Styles, 56 " vvvv ", term.DotHere, "\n", 57 " INSTANT \n", Styles, 58 "*********", 59 "hello", 60 ) 61 }