mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 21:55:15 +00:00
Add compute_patch tests for adding/removing children
This commit is contained in:
@@ -89,6 +89,74 @@ fn remove_property() {
|
||||
assert_yaml_snapshot!(patch_value);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn add_child() {
|
||||
let mut redactions = RedactionMap::new();
|
||||
|
||||
let tree = empty_tree();
|
||||
redactions.intern(tree.get_root_id());
|
||||
|
||||
let snapshot = InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("ROOT"),
|
||||
class_name: Cow::Borrowed("ROOT"),
|
||||
properties: Default::default(),
|
||||
children: vec![InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("New"),
|
||||
class_name: Cow::Borrowed("Folder"),
|
||||
properties: Default::default(),
|
||||
children: Vec::new(),
|
||||
}],
|
||||
};
|
||||
|
||||
let patch_set = compute_patch_set(&snapshot, &tree, tree.get_root_id());
|
||||
let patch_value = redactions.redacted_yaml(patch_set);
|
||||
|
||||
assert_yaml_snapshot!(patch_value);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remove_child() {
|
||||
let mut redactions = RedactionMap::new();
|
||||
|
||||
let mut tree = empty_tree();
|
||||
redactions.intern(tree.get_root_id());
|
||||
|
||||
{
|
||||
let root_id = tree.get_root_id();
|
||||
let new_id = tree.insert_instance(
|
||||
InstancePropertiesWithMeta {
|
||||
properties: RbxInstanceProperties {
|
||||
name: "Should not appear in snapshot".to_owned(),
|
||||
class_name: "Folder".to_owned(),
|
||||
properties: Default::default(),
|
||||
},
|
||||
metadata: Default::default(),
|
||||
},
|
||||
root_id,
|
||||
);
|
||||
|
||||
redactions.intern(new_id);
|
||||
}
|
||||
|
||||
let snapshot = InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(),
|
||||
name: Cow::Borrowed("ROOT"),
|
||||
class_name: Cow::Borrowed("ROOT"),
|
||||
properties: Default::default(),
|
||||
children: Vec::new(),
|
||||
};
|
||||
|
||||
let patch_set = compute_patch_set(&snapshot, &tree, tree.get_root_id());
|
||||
let patch_value = redactions.redacted_yaml(patch_set);
|
||||
|
||||
assert_yaml_snapshot!(patch_value);
|
||||
}
|
||||
|
||||
fn empty_tree() -> RojoTree {
|
||||
RojoTree::new(InstancePropertiesWithMeta {
|
||||
properties: RbxInstanceProperties {
|
||||
|
||||
Reference in New Issue
Block a user