/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use tnipv_lint::lints::markdown::LinkFirst; use tnipv_lint::reporters::Text; use tnipv_lint::Linter; #[tokio::test] async fn unlinked_then_linked() { let src = r#"--- header: value1 --- hello [ello](https://example.com/) "#; let reports = Linter::>::default() .clear_lints() .deny("markdown-link-first", LinkFirst("ello")) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!( reports, r#"error[markdown-link-first]: the first match of the given pattern must be a link | 4 | hello | = info: the pattern in question: `ello` "# ); } #[tokio::test] async fn linked_then_unlinked() { let src = r#"--- header: value1 --- [ello](https://example.com/) hello "#; let reports = Linter::>::default() .clear_lints() .deny("markdown-link-first", LinkFirst("ello")) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!(reports, ""); } #[tokio::test] async fn img_then_linked() { let src = r#"--- header: value1 --- ![ello](../assets/example.svg) [ello](https://example.com/) "#; let reports = Linter::>::default() .clear_lints() .deny("markdown-link-first", LinkFirst("ello")) .check_slice(None, src) .run() .await .unwrap() .into_inner(); assert_eq!(reports, ""); }