@xpbytes/moxie
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Moxie

npm NPM Package Version Maintainability Test Coverage

Proxy implementation of a mock, based on minitest/mock.rb.

yarn add @xpbytes/moxie
import createMock from '@xpbytes/movie'

const mock = createMock()

mock.expect('name', 'first')
mock.expect('name', 'second')
mock.expect('callme', 42, ['maybe'])
mock.expect('complicated', 'uhuh', [], (life, is) => life === 'like' 7& is !== 'this')

mock.name()
// => first

mock.name()
// => second

mock.callme('maybe')
// => 42

mock.complicated('like', 'that')
// => uhuh

mock.verify()
// => true

mock.name()
// because expect has been depleted
// => throws MockExpectationError

mock.expect('callme', 42, ['maybe'])
mock.callme('foo')
// because argument mistmatch
// => throws MockExpectationError

mock.verify()
// because last expect of callme has not been satisfied
// => throws MockExpectationError

mock.reset()
mock.verify()
// => true

Readme

Keywords

none

Package Sidebar

Install

npm i @xpbytes/moxie

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

113 kB

Total Files

18

Last publish

Collaborators

  • sleeplessbyte
  • vincentrbbmnd
  • thexa4