Skip to content

Commit

Permalink
Regenerate tests from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
yossydev committed Feb 18, 2024
1 parent bfb83a5 commit b267c5c
Showing 1 changed file with 60 additions and 16 deletions.
76 changes: 60 additions & 16 deletions crates/oxc_linter/src/rules/jsx_a11y/anchor_is_valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,44 @@ fn test() {
let pass = vec![
(r"<Anchor />", None, None),
(r"<a {...props} />", None, None),
(r"<a href='foo' />", None, None),
(r"<a href='foo' />", Some(serde_json::json!({ "validHrefs": ["foo"] })), None),
(r"<a href={foo} />", None, None),
(r"<a href='/foo' />", None, None),
(r"<a href='https://foo.bar.com' />", None, None),
(r"<a href='/foo' />", Some(serde_json::json!({ "validHrefs": ["/foo"] })), None),
(
r"<a href='https://foo.bar.com' />",
Some(serde_json::json!({ "validHrefs": ["https://foo.bar.com"] })),
None,
),
(r"<div href='foo' />", None, None),
(r"<a href='javascript' />", None, None),
(r"<a href='javascriptFoo' />", None, None),
(
r"<a href='javascript' />",
Some(serde_json::json!({ "validHrefs": ["javascript"] })),
None,
),
(
r"<a href='javascriptFoo' />",
Some(serde_json::json!({ "validHrefs": ["javascriptFoo"] })),
None,
),
(r"<a href={`#foo`}/>", None, None),
(r"<a href={'foo'}/>", None, None),
(r"<a href={'javascript'}/>", None, None),
(r"<a href={'foo'}/>", Some(serde_json::json!({ "validHrefs": ["foo"] })), None),
(
r"<a href={'javascript'}/>",
Some(serde_json::json!({ "validHrefs": ["javascript"] })),
None,
),
(r"<a href={`#javascript`}/>", None, None),
(r"<a href='#foo' />", None, None),
(r"<a href='#javascript' />", None, None),
(r"<a href='#javascriptFoo' />", None, None),
(r"<a href='#foo' />", Some(serde_json::json!({ "validHrefs": ["#foo"] })), None),
(
r"<a href='#javascript' />",
Some(serde_json::json!({ "validHrefs": ["#javascript"] })),
None,
),
(
r"<a href='#javascriptFoo' />",
Some(serde_json::json!({ "validHrefs": ["#javascriptFoo"] })),
None,
),
(r"<UX.Layout>test</UX.Layout>", None, None),
(r"<a href={this} />", None, None),
// (r#"<Anchor {...props} />"#, Some(serde_json::json!(components))),
Expand All @@ -275,7 +299,7 @@ fn test() {
// (r#"<Link href='#foo' />"#, Some(serde_json::json!(components))),
(
r"<Link href='#foo' />",
None,
Some(serde_json::json!({ "validHrefs": ["#foo"] })),
Some(
serde_json::json!({ "jsx-a11y": { "components": { "Anchor": "a", "Link": "a" } } }),
),
Expand Down Expand Up @@ -316,14 +340,34 @@ fn test() {
// (r#"<Anchor hrefLeft='#foo' />"#, Some(serde_json::json!(componentsAndSpecialLink))),
// (r#"<UX.Layout>test</UX.Layout>"#, Some(serde_json::json!(componentsAndSpecialLink))),
(r"<a {...props} onClick={() => void 0} />", None, None),
(r"<a href='foo' onClick={() => void 0} />", None, None),
(
r"<a href='foo' onClick={() => void 0} />",
Some(serde_json::json!({ "validHrefs": ["foo"] })),
None,
),
(r"<a href={foo} onClick={() => void 0} />", None, None),
(r"<a href='/foo' onClick={() => void 0} />", None, None),
(r"<a href='https://foo.bar.com' onClick={() => void 0} />", None, None),
(
r"<a href='/foo' onClick={() => void 0} />",
Some(serde_json::json!({ "validHrefs": ["/foo"] })),
None,
),
(
r"<a href='https://foo.bar.com' onClick={() => void 0} />",
Some(serde_json::json!({ "validHrefs": ["https://foo.bar.com"] })),
None,
),
(r"<div href='foo' onClick={() => void 0} />", None, None),
(r"<a href={`#foo`} onClick={() => void 0} />", None, None),
(r"<a href={'foo'} onClick={() => void 0} />", None, None),
(r"<a href='#foo' onClick={() => void 0} />", None, None),
(
r"<a href={'foo'} onClick={() => void 0} />",
Some(serde_json::json!({ "validHrefs": ["foo"] })),
None,
),
(
r"<a href='#foo' onClick={() => void 0} />",
Some(serde_json::json!({ "validHrefs": ["#foo"] })),
None,
),
(r"<a href={this} onClick={() => void 0} />", None, None),
// (r#"<Anchor {...props} onClick={() => void 0} />"#, Some(serde_json::json!(components))),
// (r#"<Anchor href='foo' onClick={() => void 0} />"#, Some(serde_json::json!(components))),
Expand Down

0 comments on commit b267c5c

Please sign in to comment.