github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/edit/instant_test.go (about)

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