# chainsinon

> A sinon utility function to return complex stubbed objects.

Latest version **0.1.1** (published 2014-08-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install chainsinon
pnpm add chainsinon
yarn add chainsinon
bun add chainsinon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2014-08-28 |
| First published | 2014-08-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dane Summers |
| Maintainers | dsummersl |
| Keywords | sinon, testing, stub, mock |

## Links

- npm: https://www.npmjs.com/package/chainsinon
- Repository: https://github.com/dsummersl/chainsinon
- Issues: https://github.com/dsummersl/chainsinon/issues
- npm.io page: https://npm.io/package/chainsinon

## Dependencies (1)

- [sinon](https://npm.io/package/sinon.md) ^1.10.3

## Alternatives

- [pagerjs](https://npm.io/package/pagerjs.md) — 60 weekly downloads
- [whistle.savefor-mock](https://npm.io/package/whistle.savefor-mock.md) — 4 weekly downloads
- [@crvouga/mockingbird-service-junction](https://npm.io/package/@crvouga/mockingbird-service-junction.md) — 0 weekly downloads
- [@crvouga/mockingbird-service-medplum](https://npm.io/package/@crvouga/mockingbird-service-medplum.md) — 0 weekly downloads
- [@crvouga/mockingbird-service-genebygene](https://npm.io/package/@crvouga/mockingbird-service-genebygene.md) — 0 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2014-08-28
- 0.1.0 — 2014-08-28

## README

chainsinon
==========

A [Sinon](http://sinonjs.org) utility function to return complex stubbed objects.

Install
=======

Use npm:

    npm install --save-dev chainsinon

Usage
=====

The chainsinon function [stubs](http://sinonjs.org/docs/#stubs) an arbitrary
list of functions on an object. For example:

    var chainsinon = require("chainsinon");

    var mockObject = chainsinon("mainMethod.subFunction.subSubFunction");

    // One can then call any of the functions mentioned:
    mockObject.mainMethod();
    mockObject.mainMethod().subFunction().subSubFunction();

    // Each mocked method is a sinon stub. You can apply custom behavior or
    // verifications on the objects as per usual...
    mockObject["mainMethod.subFunction.subSubFunction"].returns(4);

    // so this now returns 4:
    mockObject.mainMethod().subFunction().subSubFunction();

    // call counts are of course respected:
    mockObject["mainMethod"].called;    // == true
    mockObject["mainMethod"].callCount; // == 3 (three times so far)

See test cases for more examples.

---
_Source: https://npm.io/package/chainsinon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
