Skip to main content

PlayerHumanoidBinderTestUtils

Shared harness for the PlayerCharacterBinder/PlayerHumanoidBinder specs. [setup] boots a binder the way production does -- registered on a BinderProvider driven through a ServiceBag -- with the boot split into init()/start() so a test can stage mocks before the binder starts. Mocks are created through the bag's PlayerMockService (so discovery mirrors a real join, and teardown destroys them -- discovery is place-wide, so a leaked mock would bleed into the next test), and characters are plain Models with a real Humanoid.

Tags are global and the test place is shared across a batch run, so every controller derives a distinct tag from a single module-level counter, parents everything under its own container, and tears it all down via destroy().

Functions

makeTrackingClass

PlayerHumanoidBinderTestUtils.makeTrackingClass() → TrackingClass

A minimal bound class that records its instance and whether it was destroyed. It ignores its constructor varargs: the ServiceBag is injected as a constructor arg, and its Signals' strict __index makes jest's deep-equality traversal throw, so the class must not retain it for toEqual to compare instances safely.

awaitUnbound

PlayerHumanoidBinderTestUtils.awaitUnbound(
binderBinder,
instInstance
) → ()

Returns once inst is no longer bound. Removal is usually already done by the time we check; the guarded wait also covers a deferred case.

setup

PlayerHumanoidBinderTestUtils.setup(
tagPrefixstring,--

keeps tags distinct between the two spec files

constructorany?--

defaults to a fresh tracking class

) → {...}

Builds the controller the specs share around one binder of the given class. init() registers and Init's the bag (mocks can then be staged), start() starts it, boot() does both. newMock() creates a player through the bag's PlayerMockService; newCharacter() builds a character Model (with a real Humanoid unless withHumanoid is false); setCharacter() assigns the mock's stand-in Character.

Show raw api
{
    "functions": [
        {
            "name": "makeTrackingClass",
            "desc": "A minimal bound class that records its instance and whether it was destroyed. It ignores its\nconstructor varargs: the ServiceBag is injected as a constructor arg, and its Signals' strict\n__index makes jest's deep-equality traversal throw, so the class must not retain it for toEqual to\ncompare instances safely.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TrackingClass"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 38,
                "path": "src/playerhumanoidbinder/src/Server/PlayerHumanoidBinderTestUtils.lua"
            }
        },
        {
            "name": "awaitUnbound",
            "desc": "Returns once `inst` is no longer bound. Removal is usually already done by the time we check; the\nguarded wait also covers a deferred case.",
            "params": [
                {
                    "name": "binder",
                    "desc": "",
                    "lua_type": "Binder"
                },
                {
                    "name": "inst",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 61,
                "path": "src/playerhumanoidbinder/src/Server/PlayerHumanoidBinderTestUtils.lua"
            }
        },
        {
            "name": "setup",
            "desc": "Builds the controller the specs share around one binder of the given class. init() registers and\nInit's the bag (mocks can then be staged), start() starts it, boot() does both. newMock() creates a\nplayer through the bag's PlayerMockService; newCharacter() builds a character Model (with a real\nHumanoid unless withHumanoid is false); setCharacter() assigns the mock's stand-in Character.",
            "params": [
                {
                    "name": "binderClass",
                    "desc": "",
                    "lua_type": "PlayerCharacterBinder | PlayerHumanoidBinder"
                },
                {
                    "name": "tagPrefix",
                    "desc": "keeps tags distinct between the two spec files",
                    "lua_type": "string"
                },
                {
                    "name": "constructor",
                    "desc": "defaults to a fresh tracking class",
                    "lua_type": "any?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ ... }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 78,
                "path": "src/playerhumanoidbinder/src/Server/PlayerHumanoidBinderTestUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PlayerHumanoidBinderTestUtils",
    "desc": "Shared harness for the PlayerCharacterBinder/PlayerHumanoidBinder specs. [setup] boots a binder the\nway production does -- registered on a [BinderProvider] driven through a [ServiceBag] -- with the boot\nsplit into init()/start() so a test can stage mocks before the binder starts. Mocks are created\nthrough the bag's [PlayerMockService] (so discovery mirrors a real join, and teardown destroys them --\ndiscovery is place-wide, so a leaked mock would bleed into the next test), and characters are plain\nModels with a real Humanoid.\n\nTags are global and the test place is shared across a batch run, so every controller derives a\ndistinct tag from a single module-level counter, parents everything under its own container, and\ntears it all down via destroy().",
    "source": {
        "line": 16,
        "path": "src/playerhumanoidbinder/src/Server/PlayerHumanoidBinderTestUtils.lua"
    }
}