diff --git a/tests/samples/topic_deleted.html b/tests/samples/topic_deleted.html
new file mode 100644
index 0000000..6283f1c
--- /dev/null
+++ b/tests/samples/topic_deleted.html
@@ -0,0 +1,41 @@
+
+
+
+
+ Deleted topic sample for topic.rs
+
+
+
+
+
+
+
+ Topic deleted by author
+
+
+
+
+
+
+
diff --git a/tests/samples/topic_link.html b/tests/samples/topic_link.html
new file mode 100644
index 0000000..2163900
--- /dev/null
+++ b/tests/samples/topic_link.html
@@ -0,0 +1,50 @@
+
+
+
+
+ Link topic sample for topic.rs
+
+
+
+
+
+
+
+ 10
+ votes
+
+ Link Topic Title
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/samples/topic_scheduled.html b/tests/samples/topic_scheduled.html
new file mode 100644
index 0000000..b6600a6
--- /dev/null
+++ b/tests/samples/topic_scheduled.html
@@ -0,0 +1,46 @@
+
+
+
+
+ Text topic sample for topic.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/samples/topic_text.html b/tests/samples/topic_text.html
new file mode 100644
index 0000000..06d7947
--- /dev/null
+++ b/tests/samples/topic_text.html
@@ -0,0 +1,54 @@
+
+
+
+
+ Text topic sample for topic.rs
+
+
+
+
+
+
+
+ 5
+ votes
+
+ Text Topic Title
+
+
+ Posted
+
+ by
+
User
+
+
+
+
+
+
+
+
+ This topic is locked. New comments can not be posted.
+
+
+
+
+
+
+
+
diff --git a/tests/snapshots/topic__deleted.snap b/tests/snapshots/topic__deleted.snap
new file mode 100644
index 0000000..7b9bea9
--- /dev/null
+++ b/tests/snapshots/topic__deleted.snap
@@ -0,0 +1,14 @@
+---
+source: tests/topic.rs
+expression: topic
+---
+Topic {
+ author: Unknown,
+ comment_total: 2,
+ content: Unknown,
+ id: "666",
+ is_locked: false,
+ is_official: false,
+ tags: [],
+ vote_count: 0,
+}
diff --git a/tests/snapshots/topic__link.snap b/tests/snapshots/topic__link.snap
new file mode 100644
index 0000000..029bbc9
--- /dev/null
+++ b/tests/snapshots/topic__link.snap
@@ -0,0 +1,22 @@
+---
+source: tests/topic.rs
+expression: topic
+---
+Topic {
+ author: Name(
+ "AnotherUser",
+ ),
+ comment_total: 30,
+ content: Link(
+ "https://tildes.net/~test",
+ ),
+ id: "456",
+ is_locked: false,
+ is_official: false,
+ tags: [
+ "four",
+ "five",
+ "six",
+ ],
+ vote_count: 10,
+}
diff --git a/tests/snapshots/topic__scheduled.snap b/tests/snapshots/topic__scheduled.snap
new file mode 100644
index 0000000..74e134b
--- /dev/null
+++ b/tests/snapshots/topic__scheduled.snap
@@ -0,0 +1,18 @@
+---
+source: tests/topic.rs
+expression: topic
+---
+Topic {
+ author: Scheduled,
+ comment_total: 100,
+ content: Text(
+ "Scheduled Topic Text
",
+ ),
+ id: "789",
+ is_locked: false,
+ is_official: false,
+ tags: [
+ "recurring.weekly",
+ ],
+ vote_count: 50,
+}
diff --git a/tests/snapshots/topic__text.snap b/tests/snapshots/topic__text.snap
new file mode 100644
index 0000000..09348ff
--- /dev/null
+++ b/tests/snapshots/topic__text.snap
@@ -0,0 +1,22 @@
+---
+source: tests/topic.rs
+expression: topic
+---
+Topic {
+ author: Name(
+ "User",
+ ),
+ comment_total: 15,
+ content: Text(
+ "Topic Text
",
+ ),
+ id: "123",
+ is_locked: true,
+ is_official: false,
+ tags: [
+ "one",
+ "two",
+ "three",
+ ],
+ vote_count: 5,
+}
diff --git a/tests/topic.rs b/tests/topic.rs
new file mode 100644
index 0000000..1a80506
--- /dev/null
+++ b/tests/topic.rs
@@ -0,0 +1,14 @@
+use std::fs::read_to_string;
+
+use {insta::assert_debug_snapshot, tildes_parser::Topic};
+
+#[test]
+fn test_topic_parsing() {
+ let samples = ["link", "text", "deleted", "scheduled"];
+ for sample in samples {
+ let html =
+ read_to_string(format!("tests/samples/topic_{sample}.html")).unwrap();
+ let topic = &html.parse::().unwrap();
+ assert_debug_snapshot!(sample, topic);
+ }
+}
2 comments
+