diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/output.zig | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/test/output.zig b/test/output.zig index 478f1b4a..d9d41e28 100644 --- a/test/output.zig +++ b/test/output.zig @@ -952,7 +952,7 @@ test "N exactly reverses n across output panes and the ring seam" { try std.testing.expect(saw_first and saw_second); } -test "ThemeSel groups native themes first and skips headings in both directions" { +test "ThemeSel lists the ring in sections and skips headings in both directions" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); defer p.deinit(); const source = try p.setTestFile("notes\n"); @@ -966,17 +966,35 @@ test "ThemeSel groups native themes first and skips headings in both directions" try std.testing.expectEqual(@as(i32, 0), list.body.cur_row); try std.testing.expectEqual(@as(usize, 0), list.file.?.scroll); try std.testing.expectEqualStrings("# Pardes themes", modal.lineSlice(content, 0)); - try std.testing.expectEqualStrings("# Legacy and imported themes", modal.lineSlice(content, pardes.native_theme_count + 2)); - try std.testing.expectEqual(@as(usize, pardes.themes.len + 3), std.mem.count(u8, content, "\n")); + // Every theme in ring order, each section's heading after a blank line + // where colors.groupAt says one starts. + var row: usize = 1; + var sections: usize = 1; + var first_break: ?usize = null; for (pardes.themes, 0..) |theme, i| { - const row = i + 1 + @as(usize, if (i >= pardes.native_theme_count) 2 else 0); + if (i > 0) if (pardes.colors.groupAt(i)) |title| { + try std.testing.expectEqualStrings("", modal.lineSlice(content, row)); + try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(content, row + 1), "# ")); + try std.testing.expectEqualStrings(title, modal.lineSlice(content, row + 1)["# ".len..]); + row += 2; + sections += 1; + if (first_break == null) first_break = i; + }; const line = modal.lineSlice(content, row); try std.testing.expect(std.mem.startsWith(u8, line, "Theme ")); try std.testing.expectEqualStrings(theme.name, line["Theme ".len..]); + row += 1; } + try std.testing.expectEqual(pardes.themes.len + 1 + 2 * (sections - 1), std.mem.count(u8, content, "\n")); + // acme is a current theme: it is listed before any break. + const acme = for (pardes.themes, 0..) |t, i| { + if (std.mem.eql(u8, t.name, "acme")) break i; + } else return error.MissingAcme; + const brk = first_break orelse return error.NoSections; + try std.testing.expect(acme < brk); // Opening an imported theme's selector must still begin with the natives. // Walk across the section break without selecting or executing a heading. - for (pardes.themes[0 .. pardes.native_theme_count + 1]) |theme| { + for (pardes.themes[0 .. brk + 1]) |theme| { p.update(.{ .key = .{ .cp = 'n' } }); try std.testing.expectEqual(tid, p.active); const selected = selectedOutputText(list) orelse return error.MissingThemeSelection; @@ -985,9 +1003,9 @@ test "ThemeSel groups native themes first and skips headings in both directions" } p.update(.{ .key = .{ .cp = 'N' } }); const previous = selectedOutputText(list) orelse return error.MissingThemeSelection; - try std.testing.expectEqualStrings(pardes.themes[pardes.native_theme_count - 1].name, previous["Theme ".len..]); + try std.testing.expectEqualStrings(pardes.themes[brk - 1].name, previous["Theme ".len..]); p.update(.{ .key = .{ .cp = Key.tab } }); - try std.testing.expectEqual(pardes.native_theme_count - 1, p.settings.theme); + try std.testing.expectEqual(brk - 1, p.settings.theme); } test "n/N selects command outputs by whole row" { |
