slp-sdk-mock

1.0.2 • Public • Published

slp-sdk-mock

Greenkeeper badge

This is a mocking library for SLP JavaScript SDK. If you write an app that depends on the SLP SDK library, you can use this mocking library to write unit tests.

Unit tests should not call external services. That's the primary difference between unit tests and integration tests. Instead of making live calls with BITBOX, this mocking library can be used instead.

Usage

In a normal app, you would instantiate BITBOX accordingly:

const SLPSDK = require('slp-sdk')
const SLP = new SLPSDK()

const result = SLP.Utils.validTxid(someTxid)

In your unit tests, you can use this mocking library to replace the BITBOX object like so:

const SLP = require('slp-sdk-mock')

const result = SLP.Utils.validTxid(someTxid)

This mocking library depends on Sinon for mocking. If you want to mock a specific data set, you can override the default return values like this:

const sinon = require('sinon')
const SLP = require('slp-sdk-mock')

// This is an example of your own mocked data.
const myMockData = {
  txid: "1cda254d0a995c713b7955298ed246822bee487458cd9747a91d9e81d9d28125",
  valid: true
}

SLP.Utils.validTxid = sinon.stub().returns(myMockData)

const result = SLP.Utils.validTxid(someTxid)

Package Sidebar

Install

npm i slp-sdk-mock

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

3.53 kB

Total Files

4

Last publish

Collaborators

  • chris.troutner