Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-bourne committed Dec 1, 2023
1 parent 746f7d6 commit 6c1ba5f
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions packages/mdbook-rust/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ fn check(source: &str, expected: &str) {
assert_eq!(write_module(source).unwrap(), Some(expected.to_string()));
}

#[test]
fn empty() {
assert!(write_module("").unwrap().is_none());
}

#[test]
fn ignored() {
assert!(write_module(indoc! {"
fn ingnore_me() {}
"})
.unwrap()
.is_none());
}

#[test]
fn basic() {
check(
Expand All @@ -27,3 +41,98 @@ fn basic() {
"},
)
}

#[test]
fn empty_body() {
check("fn body() {}", "\n")
}

#[test]
fn line_comment_indent() {
check(
indoc! {"
fn body() {
//# No space after comment marker
//
// - Item 1
//- Item 2 with no space after comment marker
// - Sub-item
}
"},
indoc! {"
# No space after comment marker
- Item 1
- Item 2 with no space after comment marker
- Sub-item
"},
)
}

#[test]
fn block_comment_indent() {
check(
indoc! {"
fn body() {
/*
# Heading
- Item 1
- Item 2
- Sub-item
*/
}
"},
indoc! {"
# Heading
- Item 1
- Item 2
- Sub-item
"},
)
}

#[test]
fn code_only() {
check(
indoc! {"
fn body() {
let x = 1;
let y = 1;
}
"},
indoc! {"
```rust
let x = 1;
let y = 1;
```
"},
)
}

#[test]
fn code_spacing() {
check(
indoc! {"
fn body() {
let x = 1;
let y = 1;
}
"},
indoc! {"
```rust
let x = 1;
let y = 1;
```
"},
)
}

0 comments on commit 6c1ba5f

Please sign in to comment.