# 007

> Returns a deep copy of an object with all functions converted to spies

Latest version **0.0.2** (published 2013-07-29) · MIT license · 0 weekly downloads

## Install

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

## 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.0.2 |
| Published | 2013-07-29 |
| First published | 2013-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Brian Ford |
| Maintainers | btford |
| Keywords | testing, test, mock, spy |

## Links

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

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2013-07-29
- 0.0.1 — 2013-07-26
- 0.0.0 — 2013-07-26

## README

# 007
[![Build Status](https://travis-ci.org/btford/007.png?branch=master)](https://travis-ci.org/btford/007)

Returns a deep copy of an object with all functions converted to spies.

## Install

Install with `npm`:

```
npm install 007
```

## Example

```
// we want to test github
var github = require('github');
var doubleOhSeven = require('007');
var mockGithub = doubleOhSeven(github);

mockGithub.pullRequests.getCommits.returns = function () {
  return {
    foo: 'beep'
  };
};

assert(mockGithub.pullRequests.getCommits('lalala').foo === 'beep');
assert(mockGithub.pullRequests.getCommits.callCount === 1);

```

## API

### `doubleOhSeven()`

Takes an object or function as an argument, returns a function or object matching the original, but with mocked out functions.

### `mockFn.implementation`

The implementation of the mock function.
Set with `=`:

Ex:
```
mockFn.implementation = function (val, cb) {
  return cb(val + 1);
};
```

The following functions are helpers for implementation; using them will override `mockFn.implementation`.

#### `mockFn.returns()`

The return value of the mock.

Ex:
```
mockFn.returns('foo');
mockFn(function (arg) {
  console.log(arg); // outputs 'foo'
});
```

#### `mockFn.callbackArgs()`

The callback args to be invoked by the mock.

Ex:
```
mockFn.callbackArgs(['foo']);
mockFn(function (arg) {
  console.log(arg); // outputs 'foo'
});
```

## License
MIT

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