Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Aug 31, 2024
1 parent 2b53b44 commit 417d16a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion crates/unavi-scripting/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod tests {
}

assert_eq!(found_constructs, 1);
assert_eq!(found_updates, UPDATES);
assert_eq!(found_updates, 1);

Ok(())
});
Expand Down
11 changes: 6 additions & 5 deletions crates/unavi-scripting/src/api/wired_scene/gltf/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,15 +470,16 @@ mod tests {
fn test_new() {
let (mut world, mut state) = init_test_state();

let _ = HostNode::new(&mut state).unwrap();
let res = HostNode::new(&mut state).unwrap();

world.commands().append(&mut state.commands);
world.flush_commands();

let (found_id, _) = world
.query::<(&NodeId, &bevy::prelude::Transform)>()
.single(&world);
assert_eq!(found_id.0, 1);
world
.query::<&NodeId>()
.iter(&world)
.find(|n| n.0 == res.rep())
.unwrap();
}

#[test]
Expand Down
17 changes: 13 additions & 4 deletions crates/unavi-scripting/src/api/wired_scene/gltf/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ mod tests {
let root_ent = world.spawn_empty().id();
let mut state = StoreState::new("test".to_string(), root_ent, Handle::default());

let _ = HostScene::new(&mut state).unwrap();
let res = HostScene::new(&mut state).unwrap();

world.commands().append(&mut state.commands);
world.flush_commands();

let (found_id, _) = world.query::<(&SceneId, &Handle<Scene>)>().single(&world);
assert_eq!(found_id.0, 1);
world
.query::<&SceneId>()
.iter(&world)
.find(|n| n.0 == res.rep())
.unwrap();
}

#[test]
Expand All @@ -185,12 +188,18 @@ mod tests {

let scene = HostScene::new(&mut state).unwrap();
let node = HostNode::new(&mut state).unwrap();
let node_rep = node.rep();
HostScene::add_node(&mut state, scene, node).unwrap();

world.commands().append(&mut state.commands);
world.flush_commands();

let (node_ent, _) = world.query::<(Entity, &NodeId)>().single(&world);
let (node_ent, _) = world
.query::<(Entity, &NodeId)>()
.iter(&world)
.find(|(_, n)| n.0 == node_rep)
.unwrap();

let (scene_children, _) = world.query::<(&Children, &SceneId)>().single(&world);
assert!(scene_children.contains(&node_ent));
}
Expand Down
3 changes: 1 addition & 2 deletions crates/unavi-scripting/src/api/wired_scene/glxf/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,8 @@ mod tests {
world.commands().append(&mut state.commands);
world.flush_commands();

let (found_id, _) = world
world
.query::<(&GlxfNodeId, &bevy::prelude::Transform)>()
.single(&world);
assert_eq!(found_id.0, 1);
}
}
11 changes: 6 additions & 5 deletions crates/unavi-scripting/src/api/wired_scene/glxf/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,16 @@ mod tests {
fn test_new() {
let (mut world, mut state) = init_test_state();

let _ = HostGlxfScene::new(&mut state).unwrap();
let res = HostGlxfScene::new(&mut state).unwrap();

world.commands().append(&mut state.commands);
world.flush_commands();

let (found_id, _) = world
.query::<(&GlxfSceneId, &Handle<Scene>)>()
.single(&world);
assert_eq!(found_id.0, 1);
world
.query::<&GlxfSceneId>()
.iter(&world)
.find(|n| n.0 == res.rep())
.unwrap();
}

#[test]
Expand Down

0 comments on commit 417d16a

Please sign in to comment.