Skip to content

Commit

Permalink
html snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
aslilac committed May 12, 2024
1 parent 5b977e0 commit ea213d8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fs;
use std::path::Path;
use std::process::Command;

Expand Down Expand Up @@ -105,6 +106,20 @@ fn self_check_blame() {
assert!(stdout.contains("./src/main.rs"));
}

#[test]
fn self_check_html() {
setup::before();

let result = Command::new(EXE)
.args(["-reporter", "html"])
.output()
.unwrap();
assert!(result.status.success());
let stdout = String::from_utf8_lossy(&result.stdout);

assert_eq!(include_str!("./testdata/kc.html"), stdout);
}

#[test]
fn scan_nonexistent() {
setup::before();
Expand Down
72 changes: 72 additions & 0 deletions tests/testdata/kc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!doctype html>
<html>
<head>
<title>kc — .</title>
<style>
:root {
font-family: Avenir, Montserrat, Corbel, "URW Gothic", source-sans-pro, sans-serif;
font-weight: normal;
}

body {
margin: 0 auto;
padding: 48px 24px 24px;
max-width: 968px;
}

.bar {
display: flex;
gap: 2px;
border-radius: 10px;
height: 10px;
overflow: hidden;
margin-bottom: 32px;
}

.bar > * {
flex-basis: 0;
}

table {
width: 100%;
}

th {
font-size: 1.2em;
}

th:first-of-type,
td:first-of-type {
text-align: left;
}

th,
td {
text-align: right;
}

td {
border-bottom: 1px dotted black;
padding: 0.2em 0;
}
</style>
</head>
<body>

<div aria-hidden class="bar">
<div aria-hidden title="Rust" style="background-color: #a72145; flex-grow: 1636"></div>
<div aria-hidden title="CSS" style="background-color: #563d7c; flex-grow: 46"></div>
<div aria-hidden style="background-color: gray; flex-grow: 49"></div>
</div>

<table>
<colgroup><col /><col width="15%" /><col width="15%" /></colgroup>
<th>Language</th><th>Lines</th><th>Blank</th>
<tr><td><span style="color: #a72145"></span>&nbsp;Rust</td><td>1636</td><td>162</td></tr>
<tr><td><span style="color: #563d7c"></span>&nbsp;CSS</td><td>46</td><td>8</td></tr>
<tr><td><span style="color: gray"></span>&nbsp;Markdown</td><td>31</td><td>10</td></tr>
<tr><td><span style="color: gray"></span>&nbsp;TOML</td><td>18</td><td>1</td></tr>
</table>

</body>
</html>

0 comments on commit ea213d8

Please sign in to comment.