Skip to content

Commit 3ca34c9

Browse files
committed
nvim: add floating_window testcase with OpenWindowConfig
1 parent afb8303 commit 3ca34c9

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

nvim/nvim_test.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,93 @@ func TestAPI(t *testing.T) {
515515
t.Fatal(err)
516516
}
517517
})
518+
519+
t.Run("floating_window", func(t *testing.T) {
520+
clearBuffer(t, v, 0) // clear curret buffer text
521+
curwin, err := v.CurrentWindow()
522+
if err != nil {
523+
t.Fatal(err)
524+
}
525+
526+
wantWidth := 40
527+
wantHeight := 20
528+
529+
cfg := &OpenWindowConfig{
530+
Relative: "cursor",
531+
Anchor: "NW",
532+
Width: wantWidth,
533+
Height: wantHeight,
534+
Row: 1,
535+
Col: 0,
536+
Focusable: true,
537+
Style: "minimal",
538+
}
539+
w, err := v.OpenWindow(Buffer(0), true, cfg)
540+
if err != nil {
541+
t.Fatal(err)
542+
}
543+
if curwin == w {
544+
t.Fatal("same window number: floating window not focused")
545+
}
546+
547+
gotWidth, err := v.WindowWidth(w)
548+
if err != nil {
549+
t.Fatal(err)
550+
}
551+
if gotWidth != wantWidth {
552+
t.Fatalf("got %d width but want %d", gotWidth, wantWidth)
553+
}
554+
555+
gotHeight, err := v.WindowHeight(w)
556+
if err != nil {
557+
t.Fatal(err)
558+
}
559+
if gotHeight != wantHeight {
560+
t.Fatalf("got %d height but want %d", gotHeight, wantHeight)
561+
}
562+
563+
batch := v.NewBatch()
564+
var (
565+
numberOpt bool
566+
relativenumberOpt bool
567+
cursorlineOpt bool
568+
cursorcolumnOpt bool
569+
spellOpt bool
570+
listOpt bool
571+
signcolumnOpt string
572+
)
573+
batch.WindowOption(w, "number", &numberOpt)
574+
batch.WindowOption(w, "relativenumber", &relativenumberOpt)
575+
batch.WindowOption(w, "cursorline", &cursorlineOpt)
576+
batch.WindowOption(w, "cursorcolumn", &cursorcolumnOpt)
577+
batch.WindowOption(w, "spell", &spellOpt)
578+
batch.WindowOption(w, "list", &listOpt)
579+
batch.WindowOption(w, "signcolumn", &signcolumnOpt)
580+
if err := batch.Execute(); err != nil {
581+
t.Fatal(err)
582+
}
583+
if numberOpt {
584+
t.Fatal("style is minimal; expected the number window option to disabled")
585+
}
586+
if relativenumberOpt {
587+
t.Fatal("style is minimal; expected the relativenumber window option to disabled")
588+
}
589+
if cursorlineOpt {
590+
t.Fatal("style is minimal; expected the cursorline window option to disabled")
591+
}
592+
if cursorcolumnOpt {
593+
t.Fatal("style is minimal; expected the cursorcolumn window option to disabled")
594+
}
595+
if spellOpt {
596+
t.Fatal("style is minimal; expected the spell window option to disabled")
597+
}
598+
if listOpt {
599+
t.Fatal("style is minimal; expected the list window option to disabled")
600+
}
601+
if signcolumnOpt != "auto" {
602+
t.Fatalf("style is minimal; got %q but expected the signcolumn window option to \"auto\"", signcolumnOpt)
603+
}
604+
})
518605
}
519606

520607
func TestDial(t *testing.T) {

0 commit comments

Comments
 (0)