github.com/elves/elvish@v0.15.0/pkg/edit/store_api_test.go (about) 1 package edit 2 3 import ( 4 "testing" 5 6 "github.com/elves/elvish/pkg/cli" 7 "github.com/elves/elvish/pkg/eval/vals" 8 "github.com/elves/elvish/pkg/store" 9 ) 10 11 func TestCommandHistory(t *testing.T) { 12 f := setup(storeOp(func(s store.Store) { 13 s.AddCmd("echo 1") 14 s.AddCmd("echo 2") 15 })) 16 defer f.Cleanup() 17 18 // TODO(xiaq): Test session history too. 19 evals(f.Evaler, `@cmds = (edit:command-history)`) 20 testGlobal(t, f.Evaler, 21 "cmds", 22 vals.MakeList( 23 vals.MakeMap("id", "1", "cmd", "echo 1"), 24 vals.MakeMap("id", "2", "cmd", "echo 2"))) 25 } 26 27 func TestInsertLastWord(t *testing.T) { 28 f := setup(storeOp(func(s store.Store) { 29 s.AddCmd("echo foo bar") 30 })) 31 defer f.Cleanup() 32 33 evals(f.Evaler, "edit:insert-last-word") 34 wantBuf := cli.CodeBuffer{Content: "bar", Dot: 3} 35 if buf := cli.GetCodeBuffer(f.Editor.app); buf != wantBuf { 36 t.Errorf("buf = %v, want %v", buf, wantBuf) 37 } 38 }