mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
Refactor test assertions and improve code formatting
- Simplified test assertions in `fs_snapshot.rs` and `ref_properties.rs` for better readability by removing unnecessary line breaks. - Enhanced the formatting of code in `rojo_ref.rs` to maintain consistency and improve clarity. These changes improve the overall readability and maintainability of the test code and related implementations.
This commit is contained in:
parent
a741f573a4
commit
d6169c6d84
3 changed files with 11 additions and 13 deletions
|
|
@ -329,9 +329,7 @@ impl RefPathIndex {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Ok(bytes) = std::fs::read(&path) {
|
if let Ok(bytes) = std::fs::read(&path) {
|
||||||
if let Ok(val) =
|
if let Ok(val) = crate::json::from_slice::<serde_json::Value>(&bytes) {
|
||||||
crate::json::from_slice::<serde_json::Value>(&bytes)
|
|
||||||
{
|
|
||||||
if let Some(attrs) = val.get("attributes").and_then(|a| a.as_object()) {
|
if let Some(attrs) = val.get("attributes").and_then(|a| a.as_object()) {
|
||||||
for (key, value) in attrs {
|
for (key, value) in attrs {
|
||||||
if key.starts_with(crate::REF_PATH_ATTRIBUTE_PREFIX) {
|
if key.starts_with(crate::REF_PATH_ATTRIBUTE_PREFIX) {
|
||||||
|
|
|
||||||
|
|
@ -744,9 +744,7 @@ mod tests {
|
||||||
"Attachment1 wrong. Got:\n{result}"
|
"Attachment1 wrong. Got:\n{result}"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
result.contains(
|
result.contains(r#""Rojo_Ref_PrimaryPart": "Workspace/Model/Handle.model.json5""#),
|
||||||
r#""Rojo_Ref_PrimaryPart": "Workspace/Model/Handle.model.json5""#
|
|
||||||
),
|
|
||||||
"PrimaryPart wrong. Got:\n{result}"
|
"PrimaryPart wrong. Got:\n{result}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -435,8 +435,10 @@ mod tests {
|
||||||
|
|
||||||
let mut attachments = Vec::new();
|
let mut attachments = Vec::new();
|
||||||
for _ in 0..4 {
|
for _ in 0..4 {
|
||||||
let att =
|
let att = dom.insert(
|
||||||
dom.insert(container, InstanceBuilder::new("Attachment").with_name("001"));
|
container,
|
||||||
|
InstanceBuilder::new("Attachment").with_name("001"),
|
||||||
|
);
|
||||||
attachments.push(att);
|
attachments.push(att);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -489,12 +491,12 @@ mod tests {
|
||||||
|
|
||||||
let links = collect_referents(&dom2, &HashMap::new(), None);
|
let links = collect_referents(&dom2, &HashMap::new(), None);
|
||||||
|
|
||||||
let placeholders: Vec<&String> = links
|
let placeholders: Vec<&String> = links.placeholder_to_target.keys().collect();
|
||||||
.placeholder_to_target
|
|
||||||
.keys()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
assert!(placeholders.len() >= 2, "should have at least 2 placeholders");
|
assert!(
|
||||||
|
placeholders.len() >= 2,
|
||||||
|
"should have at least 2 placeholders"
|
||||||
|
);
|
||||||
|
|
||||||
let targets: HashSet<&Ref> = links.placeholder_to_target.values().collect();
|
let targets: HashSet<&Ref> = links.placeholder_to_target.values().collect();
|
||||||
assert!(
|
assert!(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue