mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
Snapshot tests for JSON models
This commit is contained in:
@@ -50,7 +50,9 @@ impl SnapshotMiddleware for SnapshotJsonModel {
|
||||
}
|
||||
}
|
||||
|
||||
let snapshot = instance.core.into_snapshot(instance_name);
|
||||
let mut snapshot = instance.core.into_snapshot(instance_name);
|
||||
|
||||
snapshot.metadata.contributing_paths = vec![entry.path().to_path_buf()];
|
||||
|
||||
Ok(Some(snapshot))
|
||||
}
|
||||
@@ -133,6 +135,7 @@ impl JsonModelCore {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use insta::assert_yaml_snapshot;
|
||||
use maplit::hashmap;
|
||||
use rbx_dom_weak::RbxValue;
|
||||
|
||||
@@ -166,27 +169,6 @@ mod test {
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
instance_snapshot,
|
||||
InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(), // TODO
|
||||
name: Cow::Borrowed("foo"),
|
||||
class_name: Cow::Borrowed("IntValue"),
|
||||
properties: hashmap! {
|
||||
"Value".to_owned() => RbxValue::Int32 {
|
||||
value: 5,
|
||||
},
|
||||
},
|
||||
children: vec![InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(), // TODO
|
||||
name: Cow::Borrowed("The Child"),
|
||||
class_name: Cow::Borrowed("StringValue"),
|
||||
properties: HashMap::new(),
|
||||
children: Vec::new(),
|
||||
},],
|
||||
}
|
||||
);
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
26
src/snapshot_middleware/snapshots/test__model_from_imfs.snap
Normal file
26
src/snapshot_middleware/snapshots/test__model_from_imfs.snap
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
source: src/snapshot_middleware/json_model.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths:
|
||||
- /foo.model.json
|
||||
project_node: ~
|
||||
name: foo
|
||||
class_name: IntValue
|
||||
properties:
|
||||
Value:
|
||||
Type: Int32
|
||||
Value: 5
|
||||
children:
|
||||
- snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths: []
|
||||
project_node: ~
|
||||
name: The Child
|
||||
class_name: StringValue
|
||||
properties: {}
|
||||
children: []
|
||||
Reference in New Issue
Block a user