mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Port SnapshotDir tests to use insta snapshots
This commit is contained in:
@@ -4,7 +4,7 @@ use rbx_dom_weak::{RbxId, RbxTree};
|
||||
|
||||
use crate::{
|
||||
imfs::{DirectorySnapshot, Imfs, ImfsEntry, ImfsFetcher, ImfsSnapshot},
|
||||
snapshot::InstanceSnapshot,
|
||||
snapshot::{InstanceMetadata, InstanceSnapshot},
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -43,7 +43,10 @@ impl SnapshotMiddleware for SnapshotDir {
|
||||
|
||||
Ok(Some(InstanceSnapshot {
|
||||
snapshot_id: None,
|
||||
metadata: Default::default(), // TODO
|
||||
metadata: InstanceMetadata {
|
||||
contributing_paths: vec![entry.path().to_path_buf()],
|
||||
..Default::default()
|
||||
},
|
||||
name: Cow::Owned(instance_name),
|
||||
class_name: Cow::Borrowed("Folder"),
|
||||
properties: HashMap::new(),
|
||||
@@ -76,6 +79,7 @@ impl SnapshotMiddleware for SnapshotDir {
|
||||
mod test {
|
||||
use super::*;
|
||||
|
||||
use insta::assert_yaml_snapshot;
|
||||
use maplit::hashmap;
|
||||
|
||||
use crate::imfs::{ImfsDebug, NoopFetcher};
|
||||
@@ -90,10 +94,7 @@ mod test {
|
||||
let entry = imfs.get("/foo").unwrap();
|
||||
let instance_snapshot = SnapshotDir::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
||||
|
||||
assert_eq!(instance_snapshot.name, "foo");
|
||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -108,15 +109,6 @@ mod test {
|
||||
let entry = imfs.get("/foo").unwrap();
|
||||
let instance_snapshot = SnapshotDir::from_imfs(&mut imfs, &entry).unwrap().unwrap();
|
||||
|
||||
assert_eq!(instance_snapshot.name, "foo");
|
||||
assert_eq!(instance_snapshot.class_name, "Folder");
|
||||
assert_eq!(instance_snapshot.properties, HashMap::new());
|
||||
assert_eq!(instance_snapshot.children.len(), 1);
|
||||
|
||||
let child = &instance_snapshot.children[0];
|
||||
assert_eq!(child.name, "Child");
|
||||
assert_eq!(child.class_name, "Folder");
|
||||
assert_eq!(child.properties, HashMap::new());
|
||||
assert_eq!(child.children, Vec::new());
|
||||
assert_yaml_snapshot!(instance_snapshot);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/snapshot_middleware/snapshots/test__empty_folder.snap
Normal file
14
src/snapshot_middleware/snapshots/test__empty_folder.snap
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
source: src/snapshot_middleware/dir.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths:
|
||||
- /foo
|
||||
project_node: ~
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children: []
|
||||
@@ -0,0 +1,24 @@
|
||||
---
|
||||
source: src/snapshot_middleware/dir.rs
|
||||
expression: instance_snapshot
|
||||
---
|
||||
snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths:
|
||||
- /foo
|
||||
project_node: ~
|
||||
name: foo
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children:
|
||||
- snapshot_id: ~
|
||||
metadata:
|
||||
ignore_unknown_instances: false
|
||||
contributing_paths:
|
||||
- /foo/Child
|
||||
project_node: ~
|
||||
name: Child
|
||||
class_name: Folder
|
||||
properties: {}
|
||||
children: []
|
||||
Reference in New Issue
Block a user