diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/keys.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig index e659b369..b6fe1e83 100644 --- a/test/behaviour/keys.zig +++ b/test/behaviour/keys.zig @@ -274,3 +274,35 @@ test "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing try std.testing.expectEqual(results, try s.focused()); try s.expect(sel, "look-owner.txt:1:7-12"); } + +/// Screen row `row` as drawn. +fn screenRow(s: *Session, row: usize) ![]const u8 { + var rows = std.mem.splitScalar(u8, try s.screen(), '\n'); + for (0..row) |_| _ = rows.next(); + return rows.next().?; +} + +test "keys: a PDF in normal mode keeps : (its tag and back), SPC (a leader, cancelled by a key it has not) and / (a search prompt, Esc closing it)" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const n = try s.lookFile("docs/design.pdf"); + const body = (try s.cursor()).?; + const tag = (try s.where("docs/design.pdf [1/"))[1]; + try s.keys(":"); + const on_tag = (try s.cursor()).?[1]; + try std.testing.expect(on_tag == tag or on_tag == tag + 1); + try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:normal ")); + try s.keys(":"); + try std.testing.expectEqual(body, (try s.cursor()).?); + // The leader shows its keys at the row's end until one it has not. + try s.keys(" "); + try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("!"); + try std.testing.expect(!std.mem.endsWith(u8, std.mem.trimEnd(u8, try screenRow(&s, body[1]), " "), " SPC")); + try s.keys("/"); + try std.testing.expect(!std.meta.eql(body, (try s.cursor()).?)); + try std.testing.expectEqual(n, try s.focused()); + try s.keys("\x1b"); + try std.testing.expectEqual(body, (try s.cursor()).?); + try std.testing.expectEqual(n, try s.focused()); +} |
