Skip to content

🔌 mock protocol for unit tests, protocol independent development and more with coffea 1.0-beta

License

Notifications You must be signed in to change notification settings

caffeinery/coffea-mock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coffea-mock

mock protocol for unit tests, protocol independent development and more with coffea 1.0-beta

Setup

  • Make sure to use the latest beta version of coffea by running: npm install --save coffea@beta
  • Install coffea-mock: npm install coffea-mock

Usage

Specify the mock protocol in your network config:

{
  "protocol": "mock"
}

You can specify a custom function to handle received message events:

{
  "protocol": "mock",
  "mock": {
    "message": (event) => console.log('message event received:', event)
  }
}

coffea will automatically load coffea-mock when it's needed! Thus, using mock (or other protocols) this way should work on any coffea project, without any tweaks (other than installing coffea-mock and specifying the config).

API

Mocking an event:

networks.send({
  type: 'mock',
  event: {
    type: 'message',
    chat: 'chat_id',
    text: 'hello world!'
  }
})

Mocking an event using a helper function:

import { message } from 'coffea'

networks.send({
  type: 'mock',
  event: message('chat_id', 'hello world!')
})

About

🔌 mock protocol for unit tests, protocol independent development and more with coffea 1.0-beta

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published