elvish/cliedit/listing_test.go

83 lines
2.0 KiB
Go
Raw Normal View History

2019-08-26 01:13:25 +08:00
package cliedit
import (
"testing"
"github.com/elves/elvish/cli/term"
"github.com/elves/elvish/store/storedefs"
"github.com/elves/elvish/ui"
)
2019-08-26 01:13:25 +08:00
/*
func TestInitListing_Binding(t *testing.T) {
// Test that the binding variable in the returned namespace indeed refers to
// the BindingMap returned.
_, binding, ns := initListing(&fakeApp{})
if ns["binding"].Get() != *binding {
t.Errorf("The binding var in the ns is not the same as the BindingMap")
}
}
*/
// Smoke tests for individual addons.
2019-08-26 01:13:25 +08:00
func TestHistlistAddon(t *testing.T) {
2019-12-02 09:19:33 +08:00
f := setup(storeOp(func(s storedefs.Store) {
s.AddCmd("ls")
s.AddCmd("echo")
s.AddCmd("ls")
2019-12-02 09:19:33 +08:00
}))
defer f.Cleanup()
2019-08-26 01:13:25 +08:00
f.TTYCtrl.Inject(term.K('R', ui.Ctrl))
f.TestTTY(t,
"~> \n",
" HISTORY (dedup on) ", Styles,
"******************** ", term.DotHere, "\n",
" 1 echo\n",
" 2 ls ", Styles,
"++++++++++++++++++++++++++++++++++++++++++++++++++",
)
evals(f.Evaler, `edit:histlist:toggle-dedup`)
f.TestTTY(t,
"~> \n",
" HISTORY ", Styles,
"********* ", term.DotHere, "\n",
" 0 ls\n",
" 1 echo\n",
" 2 ls ", Styles,
"++++++++++++++++++++++++++++++++++++++++++++++++++",
)
evals(f.Evaler, `edit:histlist:toggle-case-sensitivity`)
f.TestTTY(t,
"~> \n",
" HISTORY (case-insensitive) ", Styles,
"**************************** ", term.DotHere, "\n",
" 0 ls\n",
" 1 echo\n",
" 2 ls ", Styles,
"++++++++++++++++++++++++++++++++++++++++++++++++++",
)
2019-08-26 01:13:25 +08:00
}
func TestLastCmdAddon(t *testing.T) {
2019-12-02 09:19:33 +08:00
f := setup(storeOp(func(s storedefs.Store) {
s.AddCmd("echo hello world")
2019-12-02 09:19:33 +08:00
}))
defer f.Cleanup()
2019-08-26 01:13:25 +08:00
f.TTYCtrl.Inject(term.K(',', ui.Alt))
f.TestTTY(t,
"~> \n",
"LASTCMD ", Styles,
"******* ", term.DotHere, "\n",
" echo hello world \n", Styles,
"++++++++++++++++++++++++++++++++++++++++++++++++++",
" 0 echo\n",
" 1 hello\n",
" 2 world",
)
2019-08-26 01:13:25 +08:00
}