Skip to content

Instantly share code, notes, and snippets.

@diestrin
Last active August 30, 2019 04:49
Show Gist options
  • Select an option

  • Save diestrin/5e812ab683d86f6aa22f94948dfc0560 to your computer and use it in GitHub Desktop.

Select an option

Save diestrin/5e812ab683d86f6aa22f94948dfc0560 to your computer and use it in GitHub Desktop.
// Create the mock controller adapter
const adapter = new MockControllerAdapter();
// Create the participant client
const participantCtrl = ClientFactory(ParticipantController, adapter);
// Initialize the adapter with all the controllers
await adapter.init([...]);
// Register an user
adapter.addUser('MyUser1');
// Create the participant model
const participantModel = new Participant({
id: uuid(),
name: 'Diego'
});
// Invoke a function using the corresponding username
await participantCtrl.$withUser('MyUser1').register(participantModel);
// Retrieve the participant from network
const savedModel = await Participant.getOne(participantModel.id);
// Compare the identity assigned in the controller using `this.sender`...
expect(savedModel.identity)
// ... with the fingerprint of the mocked user
.to.eq(adapter.getUserFingerprint('MyUser1'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment