Skip to content

Commit 4e08f82

Browse files
committed
Add test for absent SceneSpawner.
1 parent a20da4c commit 4e08f82

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/scene.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ fn add_outline(
4141
mut commands: Commands,
4242
mut query: Query<(&mut AsyncSceneInheritOutline, Option<&SceneInstance>)>,
4343
systems: Res<AsyncSceneInheritOutlineSystems>,
44-
scene_spawner: Option<Res<SceneSpawner>>, // Could be temporarily removed from the world when a scene is spawning
44+
scene_spawner: Option<Res<SceneSpawner>>,
4545
) {
4646
let Ok((mut scene_outline, scene_instance)) = query.get_mut(*entity_input) else {
4747
return;
4848
};
4949
let mut ready = false;
50+
// Assume that this scene cannot be ready if the SceneSpawner is currently in use.
5051
if let (Some(scene_instance), Some(scene_spawner)) = (scene_instance, scene_spawner) {
5152
let iid = **scene_instance;
5253
if scene_spawner.instance_is_ready(iid) {
@@ -237,4 +238,20 @@ mod tests {
237238
app.update();
238239
assert_counts(&mut app, 2, 0);
239240
}
241+
242+
#[test]
243+
fn test_add_when_scene_spawner_missing() {
244+
let (mut app, scene_entity) = setup();
245+
246+
let scene_spawner = app.world_mut().remove_resource::<SceneSpawner>().unwrap();
247+
app.world_mut()
248+
.get_entity_mut(scene_entity)
249+
.unwrap()
250+
.insert(AsyncSceneInheritOutline::default());
251+
app.world_mut().flush();
252+
app.world_mut().insert_resource(scene_spawner);
253+
254+
app.update();
255+
assert_counts(&mut app, 0, 2);
256+
}
240257
}

0 commit comments

Comments
 (0)