Skip to content

Commit 49db01d

Browse files
committed
nvim: add WindowOption and SetWindowOption testcases
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent ac90e80 commit 49db01d

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

nvim/api_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,28 @@ func testWindow(v *Nvim) func(*testing.T) {
10761076
t.Fatalf("expect Key not found but fonud key")
10771077
}
10781078
})
1079+
1080+
t.Run("WindowOption", func(t *testing.T) {
1081+
wantValue := "+1"
1082+
if err := v.SetWindowOption(Window(0), "colorcolumn", &wantValue); err != nil {
1083+
t.Fatal(err)
1084+
}
1085+
1086+
var gotValue string
1087+
if err := v.WindowOption(Window(0), "colorcolumn", &gotValue); err != nil {
1088+
t.Fatal(err)
1089+
}
1090+
1091+
if gotValue != wantValue {
1092+
t.Fatalf("expected %s but got %s", wantValue, gotValue)
1093+
}
1094+
1095+
t.Cleanup(func() {
1096+
if err := v.SetWindowOption(Window(0), "colorcolumn", ""); err != nil {
1097+
t.Fatal(err)
1098+
}
1099+
})
1100+
})
10791101
})
10801102

10811103
t.Run("Batch", func(t *testing.T) {
@@ -1264,6 +1286,33 @@ func testWindow(v *Nvim) func(*testing.T) {
12641286
t.Fatalf("expect Key not found but fonud key")
12651287
}
12661288
})
1289+
1290+
t.Run("WindowOption", func(t *testing.T) {
1291+
b := v.NewBatch()
1292+
1293+
wantValue := "+1"
1294+
b.SetWindowOption(Window(0), "colorcolumn", &wantValue)
1295+
if err := b.Execute(); err != nil {
1296+
t.Fatal(err)
1297+
}
1298+
1299+
var gotValue string
1300+
b.WindowOption(Window(0), "colorcolumn", &gotValue)
1301+
if err := b.Execute(); err != nil {
1302+
t.Fatal(err)
1303+
}
1304+
1305+
if gotValue != wantValue {
1306+
t.Fatalf("expected %s but got %s", wantValue, gotValue)
1307+
}
1308+
1309+
t.Cleanup(func() {
1310+
b.SetWindowOption(Window(0), "colorcolumn", "")
1311+
if err := b.Execute(); err != nil {
1312+
t.Fatal(err)
1313+
}
1314+
})
1315+
})
12671316
})
12681317
}
12691318
}

0 commit comments

Comments
 (0)