Skip to content

Mock actor setters do not chain #1098

Description

@dahlia

Background

MockFederation.setActorDispatcher() in packages/testing/src/mock.ts returns an object whose setKeyPairsDispatcher(), mapHandle(), mapAlias(), and authorize() return the MockFederation itself instead of the setters object. Other mock setters, such as those returned by setObjectDispatcher() and the collection dispatchers, return the federation from authorize() in the same way.

So code that chains setters, as the Federation API allows, fails against the mock:

federation
  .setActorDispatcher("/users/{identifier}", dispatcher)
  .setKeyPairsDispatcher(keyPairsDispatcher)
  .mapHandle(mapper);  // TypeError: mapHandle is not a function

mapPortableActorId(), added in #840, already returns the setters object, as does the real implementation. The actor setters also lack mapActorAlias().

Proposed work

Make every setters object that the mock returns return itself from its methods, and add the missing mapActorAlias().

Tests

  • chaining every actor setter in any order;
  • chaining authorize() on object and collection setters;
  • the registered callbacks still being used by the mock context.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions