2019-12-18 18:38:21 +08:00
|
|
|
package edit
|
2019-12-08 08:29:19 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-01-27 09:28:38 +08:00
|
|
|
"src.elv.sh/pkg/cli/term"
|
2021-02-12 02:49:00 +08:00
|
|
|
"src.elv.sh/pkg/cli/tk"
|
2019-12-08 08:29:19 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestInstantAddon_ValueOutput(t *testing.T) {
|
2021-08-07 05:18:09 +08:00
|
|
|
f := setup(t)
|
2019-12-08 08:29:19 +08:00
|
|
|
|
|
|
|
evals(f.Evaler, "edit:-instant:start")
|
|
|
|
f.TestTTY(t,
|
|
|
|
"~> ", term.DotHere, "\n",
|
|
|
|
" INSTANT \n", Styles,
|
|
|
|
"*********",
|
|
|
|
)
|
|
|
|
|
|
|
|
feedInput(f.TTYCtrl, "+")
|
|
|
|
f.TestTTY(t,
|
|
|
|
"~> +", Styles,
|
|
|
|
" v", term.DotHere, "\n",
|
|
|
|
" INSTANT \n", Styles,
|
|
|
|
"*********",
|
|
|
|
"▶ 0",
|
|
|
|
)
|
|
|
|
|
|
|
|
feedInput(f.TTYCtrl, " 1 2")
|
|
|
|
f.TestTTY(t,
|
|
|
|
"~> + 1 2", Styles,
|
|
|
|
" v ", term.DotHere, "\n",
|
|
|
|
" INSTANT \n", Styles,
|
|
|
|
"*********",
|
|
|
|
"▶ 3",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInstantAddon_ByteOutput(t *testing.T) {
|
2021-08-07 05:18:09 +08:00
|
|
|
f := setup(t)
|
2019-12-08 08:29:19 +08:00
|
|
|
|
|
|
|
// We don't want to trigger the evaluation of "e", "ec", and "ech", so we
|
|
|
|
// start with a non-empty code buffer.
|
2021-02-12 05:44:41 +08:00
|
|
|
f.SetCodeBuffer(tk.CodeBuffer{Content: "echo ", Dot: 5})
|
2019-12-08 08:29:19 +08:00
|
|
|
evals(f.Evaler, "edit:-instant:start")
|
|
|
|
f.TestTTY(t,
|
|
|
|
"~> echo ", Styles,
|
|
|
|
" vvvv ", term.DotHere, "\n",
|
|
|
|
" INSTANT \n", Styles,
|
|
|
|
"*********",
|
|
|
|
)
|
|
|
|
|
|
|
|
feedInput(f.TTYCtrl, "hello")
|
|
|
|
f.TestTTY(t,
|
|
|
|
"~> echo hello", Styles,
|
|
|
|
" vvvv ", term.DotHere, "\n",
|
|
|
|
" INSTANT \n", Styles,
|
|
|
|
"*********",
|
|
|
|
"hello",
|
|
|
|
)
|
|
|
|
}
|