Skip to content

Commit

Permalink
more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it committed Feb 7, 2025
1 parent edcd124 commit 503bf08
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 2 deletions.
10 changes: 9 additions & 1 deletion build/tools.zig
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,21 @@ fn setupSnapshotTesting(b: *std.Build, scopes: []const []const u8) !void {
const diff = b.addSystemCommand(&.{
"git",
"diff",
"--cached",
"--exit-code",
});

diff.addDirectoryArg(b.path("tests/"));

test_step.dependOn(&diff.step);

// We need to stage all of tests/ in order for untracked files to show up in
// the diff. It's also not a bad automatism since it avoids the problem of
// forgetting to stage new snapshot files.
const git_add = b.addSystemCommand(&.{ "git", "add", "tests/" });

diff.step.dependOn(&git_add.step);

const tests_dir = try b.build_root.handle.openDir("tests/", .{
.iterate = true,
});
Expand Down Expand Up @@ -167,7 +175,7 @@ fn setupSnapshotTesting(b: *std.Build, scopes: []const []const u8) !void {
"src",
})));

diff.step.dependOn(&build_site.step);
git_add.step.dependOn(&build_site.step);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/simple/snapshot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<h1>Homepage</h1>
<div><p>Your <strong>SuperMD</strong> content goes here.</p></div>
<div><p>Your <strong>SuperMD</strong> content goes here.</p><h1>H1</h1><p>Lorem Ipsum 1</p><h2>H2</h2><p>Lorem Ipsum 2</p><h4>H3</h4><p>Lorem Ipsum 3</p></div>
</body>
</html>
30 changes: 30 additions & 0 deletions tests/simple/snapshot/sections/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Simple Test Website</title>
</head>
<body>
<h1>Sections</h1>
<div>
<h2>-- TABLE OF CONTENTS --</h2>
<ul>
<li><a href="#h1">H1</a><ul><li>
<a href="#h2">H2</a><ul><li>
<a href="#h3">H3</a></li></ul></li></ul></ul>
</div>
<div>
<h2>-- SECTION BEGIN --</h2>
<div><div id="h1"><h1><a class="" href="#h1">H1</a></h1><p>Lorem Ipsum 1</p></div></div>
<h2>-- SECTION END --</h2>

<h2>-- SECTION BEGIN --</h2>
<div><div id="h2"><h2><a class="" href="#h2">H2</a></h2><p>Lorem Ipsum 2</p></div></div>
<h2>-- SECTION END --</h2>

<h2>-- SECTION BEGIN --</h2>
<div><div id="h3"><h3><a class="" href="#h3">H3</a></h3><p>Lorem Ipsum 3</p></div></div>
<h2>-- SECTION END --</h2>
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions tests/simple/src/content/index.smd
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@
.draft = false,
---
Your **SuperMD** content goes here.


# H1
Lorem Ipsum 1

## H2
Lorem Ipsum 2

#### H3
Lorem Ipsum 3

17 changes: 17 additions & 0 deletions tests/simple/src/content/sections.smd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
.title = "Sections",
.date = @date("2020-07-06T00:00:00"),
.author = "Sample Author",
.layout = "sections.shtml",
.draft = false,
---

# [H1]($section.id('h1'))
Lorem Ipsum 1

## [H2]($section.id('h2'))
Lorem Ipsum 2

### [H3]($section.id('h3'))
Lorem Ipsum 3

19 changes: 19 additions & 0 deletions tests/simple/src/layouts/sections.shtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title :text="$site.title"></title>
</head>
<body>
<h1 :text="$page.title"></h1>
<div>
<h2>-- TABLE OF CONTENTS --</h2>
<ctx :html="$page.toc()"></ctx>
</div>
<div :loop="$page.contentSections()">
<h2>-- SECTION BEGIN --</h2>
<div :html="$loop.it.html()"></div>
<h2>-- SECTION END --</h2>
</div>
</body>
</html>

0 comments on commit 503bf08

Please sign in to comment.