mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +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);
|
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 {
|
fn empty_tree() -> RojoTree {
|
||||||
RojoTree::new(InstancePropertiesWithMeta {
|
RojoTree::new(InstancePropertiesWithMeta {
|
||||||
properties: RbxInstanceProperties {
|
properties: RbxInstanceProperties {
|
||||||
|
|||||||
18
src/snapshot/tests/snapshots/compute__add_child.snap
Normal file
18
src/snapshot/tests/snapshots/compute__add_child.snap
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot/tests/compute.rs
|
||||||
|
expression: patch_value
|
||||||
|
---
|
||||||
|
removed_instances: []
|
||||||
|
added_instances:
|
||||||
|
- parent_id: id-1
|
||||||
|
instance:
|
||||||
|
snapshot_id: ~
|
||||||
|
metadata:
|
||||||
|
ignore_unknown_instances: false
|
||||||
|
source_path: ~
|
||||||
|
project_node: ~
|
||||||
|
name: New
|
||||||
|
class_name: Folder
|
||||||
|
properties: {}
|
||||||
|
children: []
|
||||||
|
updated_instances: []
|
||||||
8
src/snapshot/tests/snapshots/compute__remove_child.snap
Normal file
8
src/snapshot/tests/snapshots/compute__remove_child.snap
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
source: src/snapshot/tests/compute.rs
|
||||||
|
expression: patch_value
|
||||||
|
---
|
||||||
|
removed_instances:
|
||||||
|
- id-2
|
||||||
|
added_instances: []
|
||||||
|
updated_instances: []
|
||||||
Reference in New Issue
Block a user