2019-08-26 01:13:25 +08:00
|
|
|
package cliedit
|
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/elves/elvish/cli/term"
|
|
|
|
"github.com/elves/elvish/store/storedefs"
|
2019-11-29 08:01:27 +08:00
|
|
|
"github.com/elves/elvish/ui"
|
2019-11-09 22:56:54 +08:00
|
|
|
)
|
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
// Smoke tests for individual addons.
|
2019-08-26 01:13:25 +08:00
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
func TestHistlistAddon(t *testing.T) {
|
2019-12-02 09:19:33 +08:00
|
|
|
f := setup(storeOp(func(s storedefs.Store) {
|
2019-11-16 08:05:03 +08:00
|
|
|
s.AddCmd("ls")
|
|
|
|
s.AddCmd("echo")
|
|
|
|
s.AddCmd("ls")
|
2019-12-02 09:19:33 +08:00
|
|
|
}))
|
2019-11-09 22:56:54 +08:00
|
|
|
defer f.Cleanup()
|
2019-08-26 01:13:25 +08:00
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
f.TTYCtrl.Inject(term.K('R', ui.Ctrl))
|
2019-12-08 05:24:00 +08:00
|
|
|
f.TestTTY(t,
|
|
|
|
"~> \n",
|
|
|
|
" HISTORY (dedup on) ", Styles,
|
|
|
|
"******************** ", term.DotHere, "\n",
|
|
|
|
" 1 echo\n",
|
|
|
|
" 2 ls ", Styles,
|
|
|
|
"++++++++++++++++++++++++++++++++++++++++++++++++++",
|
|
|
|
)
|
2019-11-16 08:05:03 +08:00
|
|
|
|
|
|
|
evals(f.Evaler, `edit:histlist:toggle-dedup`)
|
2019-12-08 05:24:00 +08:00
|
|
|
f.TestTTY(t,
|
|
|
|
"~> \n",
|
|
|
|
" HISTORY ", Styles,
|
|
|
|
"********* ", term.DotHere, "\n",
|
|
|
|
" 0 ls\n",
|
|
|
|
" 1 echo\n",
|
|
|
|
" 2 ls ", Styles,
|
|
|
|
"++++++++++++++++++++++++++++++++++++++++++++++++++",
|
|
|
|
)
|
2019-11-16 08:05:03 +08:00
|
|
|
|
|
|
|
evals(f.Evaler, `edit:histlist:toggle-case-sensitivity`)
|
2019-12-08 05:24:00 +08:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
func TestLastCmdAddon(t *testing.T) {
|
2019-12-02 09:19:33 +08:00
|
|
|
f := setup(storeOp(func(s storedefs.Store) {
|
2019-11-09 22:56:54 +08:00
|
|
|
s.AddCmd("echo hello world")
|
2019-12-02 09:19:33 +08:00
|
|
|
}))
|
2019-11-09 22:56:54 +08:00
|
|
|
defer f.Cleanup()
|
2019-08-26 01:13:25 +08:00
|
|
|
|
2019-11-09 22:56:54 +08:00
|
|
|
f.TTYCtrl.Inject(term.K(',', ui.Alt))
|
2019-12-08 05:24:00 +08:00
|
|
|
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
|
|
|
}
|