Repository: bevyengine/bevy
File: crates/bevy_scene/src/lib.rs (Rust)

Code before:
        };

        let mut scene_1 = Scene {
            world: World::new(),
        };
        let root = scene_1.world.spawn_empty().id();
        scene_1.world.spawn((
            Rectangle {
                width: 10.0,
                height: 5.0,
            },
            FinishLine,
            ChildOf(root),
        ));
        scene_1.world.spawn((Circle { radius: 7.0 }, ChildOf(root)));

        let scene_1 = create_dynamic_scene(scene_1, app.world());
        app.world_mut()
            .resource_mut::<Assets<DynamicScene>>()
            .insert(&scene_handle, scene_1);

        app.update();
        app.update();
        app.update();
        app.update();

        let child_root = app
            .world()
            .entity(scene_entity)
            .get::<Children>()
            .and_then(|children| children.first().cloned())
            .expect("There should be exactly one child on the scene root");
        let children = app
            .world()
            .entity(child_root)
            .get::<Children>()
            .expect("The child of the scene root should itself have 2 children");
        assert_eq!(children.len(), 2);

        let finish_line = app.world().entity(children[0]);
        assert_eq!(finish_line.archetype().component_count(), 3);
        let (rectangle, _, child_of) =
            finish_line.components::<(&Rectangle, &FinishLine, &ChildOf)>();
        assert_eq!(
            rectangle,
            &Rectangle {
                width: 10.0,
                height: 5.0,
            }
        );
        assert_eq!(child_of.0, child_root);

Review comment (suggestion):
```suggestion
        // TODO: multiple updates to avoid debounced asset events. See comment on SceneSpawner::debounced_scene_asset_events
        app.update();
```

Code after:
                .build()
        };

        let mut scene_1 = Scene {
            world: World::new(),
        };
        let root = scene_1.world.spawn_empty().id();
        scene_1.world.spawn((
            Rectangle {
                width: 10.0,
                height: 5.0,
            },
            FinishLine,
            ChildOf(root),
        ));
        scene_1.world.spawn((Circle { radius: 7.0 }, ChildOf(root)));

        let scene_1 = create_dynamic_scene(scene_1, app.world());
        app.world_mut()
            .resource_mut::<Assets<DynamicScene>>()
            .insert(&scene_handle, scene_1)
            .unwrap();

        app.update();
        // TODO: multiple updates to avoid debounced asset events. See comment on SceneSpawner::debounced_scene_asset_events
        app.update();
        app.update();
        app.update();

        let child_root = app
            .world()
            .entity(scene_entity)
            .get::<Children>()
            .and_then(|children| children.first().cloned())
            .expect("There should be exactly one child on the scene root");
        let children = app
            .world()
            .entity(child_root)
            .get::<Children>()
            .expect("The child of the scene root should itself have 2 children");
        assert_eq!(children.len(), 2);

        let finish_line = app.world().entity(children[0]);
        assert_eq!(finish_line.archetype().component_count(), 3);
        let (rectangle, _, child_of) =
            finish_line.components::<(&Rectangle, &FinishLine, &ChildOf)>();
        assert_eq!(
            rectangle,
            &Rectangle {
                width: 10.0,
                height: 5.0,