Skip to content

Commit

Permalink
Update relative_links.rs
Browse files Browse the repository at this point in the history
Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update test.yaml

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update Cargo.toml

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update test.yaml

Update relative_links.rs

Update test.yaml

Update test.yaml

Update test.yaml

Update Cargo.toml

Update test.yaml

Update test.yaml

Update test.yaml

Update Cargo.toml

Update test.yaml

Update test.yaml

Update test.yaml

Update test.yaml

Update test.yaml

Update test.yaml

Update Cargo.toml

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update Cargo.toml

Update test.yaml

Update test.yaml

Update relative_links.rs

Update Cargo.toml

Update Cargo.toml

Update test.yaml

Update relative_links.rs

Update test.yaml

Update relative_links.rs

Update test.yaml

Update test.yaml

Update relative_links.rs

Update Cargo.toml

Update Cargo.toml

Update test.yaml

Update relative_links.rs

Update relative_links.rs

Bit of work on implementation and more tests (#5)

Update relative_links.rs

Update lint_markdown_relative_links.rs

Update relative_links.rs

Update lint_markdown_relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs

Update relative_links.rs
  • Loading branch information
JEAlfonsoP authored and SamWilsn committed May 20, 2024
1 parent 93266e6 commit a736a88
Showing 1 changed file with 147 additions and 1 deletion.
148 changes: 147 additions & 1 deletion eipw-lint/tests/lint_markdown_relative_links.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* 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/.
* file. You can obtain one at https://mozilla.org/MPL/2.0/.
*/

use eipw_lint::lints::markdown::RelativeLinks;
Expand Down Expand Up @@ -69,6 +69,63 @@ header: value1
);
}

#[tokio::test]
async fn inline_link_with_scheme_to_eips_ethereum_org() {
let src = r#"---
header: value1
---
[hello](https://eips.ethereum.org/EIPS/eip-1234)
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-rel", RelativeLinks { exceptions: &[] })

Check failure on line 83 in eipw-lint/tests/lint_markdown_relative_links.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

mismatched types
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(
reports,
r#"error[markdown-rel]: non-relative link or image
|
5 | [hello](https://eips.ethereum.org/EIPS/eip-1234)
|
= help: use `./eip-1234.md` instead
"#
);
}

#[tokio::test]
async fn inline_link_with_scheme_and_numbers() {
let src = r#"---
header: value1
---
[hi](https://example.com/4444)
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-rel", RelativeLinks { exceptions: &[] })

Check failure on line 112 in eipw-lint/tests/lint_markdown_relative_links.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

mismatched types
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(
reports,
r#"error[markdown-rel]: non-relative link or image
|
5 | [hi](https://example.com/4444)
|
"#
);
}

#[tokio::test]
async fn inline_link_protocol_relative() {
let src = r#"---
Expand Down Expand Up @@ -224,6 +281,37 @@ Hello [hi][hello]!
assert_eq!(reports, "");
}

#[tokio::test]
async fn reference_link_with_scheme_to_eips_ethereum_org() {
let src = r#"---
header: value1
---
Hello [hi][hello]!
[hello]: https://eips.ethereum.org/EIPS/eip-1234
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-rel", RelativeLinks { exceptions: &[] })

Check failure on line 297 in eipw-lint/tests/lint_markdown_relative_links.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

mismatched types
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(
reports,
r#"error[markdown-rel]: non-relative link or image
|
5 | Hello [hi][hello]!
|
= help: use `./eip-1234.md` instead
"#
);
}

#[tokio::test]
async fn inline_autolink() {
let src = r#"---
Expand Down Expand Up @@ -325,6 +413,35 @@ header: value1
);
}

#[tokio::test]
async fn anchor_link_protocol_relative_to_eips_ethereum_org() {
let src = r#"---
header: value1
---
<a href="//eips.ethereum.org/EIPS/eip-1234">example</a>
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-rel", RelativeLinks { exceptions: &[] })

Check failure on line 427 in eipw-lint/tests/lint_markdown_relative_links.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

mismatched types
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(
reports,
r#"error[markdown-rel]: non-relative link or image
|
5 | <a href="//eips.ethereum.org/EIPS/eip-1234">example</a>
|
= help: use `./eip-1234.md` instead
"#
);
}

#[tokio::test]
async fn anchor_link_relative_double_slash() {
let src = r#"---
Expand Down Expand Up @@ -409,3 +526,32 @@ header: value1
"#
);
}

#[tokio::test]
async fn img_protocol_relative_to_eips_ethereum_org() {
let src = r#"---
header: value1
---
<img src="//eips.ethereum.org/assets/eip-712/eth_sign.png">
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-rel", RelativeLinks { exceptions: &[] })

Check failure on line 541 in eipw-lint/tests/lint_markdown_relative_links.rs

View workflow job for this annotation

GitHub Actions / Test Suite (ubuntu-latest)

mismatched types
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(
reports,
r#"error[markdown-rel]: non-relative link or image
|
5 | <img src="//eips.ethereum.org/assets/eip-712/eth_sign.png">
|
= help: use `../assets/eip-712/eth_sign.png` instead
"#
);
}

0 comments on commit a736a88

Please sign in to comment.