Skip to content

Commit

Permalink
test: improve validate (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 authored Jul 9, 2024
1 parent 2681223 commit d1c7666
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, false);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, None);
}

Expand All @@ -221,6 +222,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, false);
assert_eq!(rsc.is_client_entry, true);
assert_eq!(rsc.error, None);
}

Expand All @@ -232,6 +234,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, false);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, Some(RSCError::CannotUseBothClientAndServer));
}

Expand All @@ -244,6 +247,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, false);
assert_eq!(rsc.is_client_entry, true);
assert_eq!(rsc.error, None);
}

Expand All @@ -264,6 +268,7 @@ mod tests {
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
// cannot tell if 'foo' is a server action, depends on if there's a Server component that uses it
assert_eq!(rsc.is_server_action, true);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, None);
}

Expand All @@ -278,6 +283,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, true);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, None);
}

Expand All @@ -290,6 +296,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), false).unwrap();
assert_eq!(rsc.is_server_action, false);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, None);
}

Expand All @@ -302,6 +309,7 @@ mod tests {
"#;
let rsc = validate_string(&source_text.to_string(), SourceType::from_path("test.js").unwrap(), true).unwrap();
assert_eq!(rsc.is_server_action, true);
assert_eq!(rsc.is_client_entry, false);
assert_eq!(rsc.error, None);
}
}

0 comments on commit d1c7666

Please sign in to comment.