Skip to content

Commit

Permalink
nvim: add OpenTerm testcase
Browse files Browse the repository at this point in the history
Signed-off-by: Koichi Shiraishi <zchee.io@gmail.com>
  • Loading branch information
zchee committed Jun 12, 2021
1 parent 3a212d9 commit 57a2bfa
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions nvim/nvim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func TestAPI(t *testing.T) {
t.Run("RuntimeFiles", testRuntimeFiles(v))
t.Run("AllOptionsInfo", testAllOptionsInfo(v))
t.Run("OptionsInfo", testOptionsInfo(v))
t.Run("OpenTerm", testTerm(v))
}

func testBufAttach(v *Nvim) func(*testing.T) {
Expand Down Expand Up @@ -1802,6 +1803,77 @@ func testOptionsInfo(v *Nvim) func(*testing.T) {
}
}

// TODO(zchee): correct testcase
func testTerm(v *Nvim) func(*testing.T) {
return func(t *testing.T) {
t.Run("Nvim", func(t *testing.T) {
t.Parallel()

buf, err := v.CreateBuffer(true, true)
if err != nil {
t.Fatal(err)
}

cfg := &WindowConfig{
Relative: "editor",
Width: 79,
Height: 31,
Row: 1,
Col: 1,
}
if _, err := v.OpenWindow(buf, false, cfg); err != nil {
t.Fatal(err)
}

termID, err := v.OpenTerm(buf, make(map[string]interface{}))
if err != nil {
t.Fatal(err)
}

data := "\x1b[38;2;00;00;255mTRUECOLOR\x1b[0m"
if err := v.Call("chansend", nil, termID, data); err != nil {
t.Fatal(err)
}
})

t.Run("Batch", func(t *testing.T) {
t.Parallel()

b := v.NewBatch()

var buf Buffer
b.CreateBuffer(true, true, &buf)
if err := b.Execute(); err != nil {
t.Fatal(err)
}

cfg := &WindowConfig{
Relative: "editor",
Width: 79,
Height: 31,
Row: 1,
Col: 1,
}
var win Window
b.OpenWindow(buf, false, cfg, &win)

var termID int
b.OpenTerm(buf, make(map[string]interface{}), &termID)

if err := b.Execute(); err != nil {
t.Fatal(err)
}

data := "\x1b[38;2;00;00;255mTRUECOLOR\x1b[0m"
b.Call("chansend", nil, termID, data)

if err := b.Execute(); err != nil {
t.Fatal(err)
}
})
}
}

func TestDial(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("not supported dial unix socket on windows GOOS")
Expand Down

0 comments on commit 57a2bfa

Please sign in to comment.