New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

candy-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

candy-wrapper - npm Package Compare versions

Comparing version 0.5.0 to 0.8.0

7

.jsdoc-conf.json

@@ -22,8 +22,3 @@ {

"plugins/markdown"
],
"templates": {
"default": {
"staticFiles": ["./img"]
}
}
]
}

6

package.json
{
"name": "candy-wrapper",
"version": "0.5.0",
"version": "0.8.0",
"description": "A sinon.js-like wrapper for functions that creates stubs, spys, mocks, etc.",

@@ -30,3 +30,5 @@ "main": "main.js",

"candy",
"shimmer"
"shimmer",
"monkeypatch",
"rewire"
],

@@ -33,0 +35,0 @@ "repository": {

@@ -1,2 +0,2 @@

Work in progress. Please don't use.
**This project is currently in BETA. APIs may be subject to frequent change prior to the 1.0 release. Please use very strict versioning in your `package.json` if you choose to use candy-wrapper at this time.**

@@ -7,2 +7,3 @@ ![##candy-wrapper](https://cdn.rawgit.com/apowers313/candy-wrapper/2e325ece/img/candy-wrapper-full-logo-1116x200.png?raw=true)

[![Coverage Status](https://coveralls.io/repos/github/apowers313/candy-wrapper/badge.svg?branch=master)](https://coveralls.io/github/apowers313/candy-wrapper?branch=master)
[![Stories in Ready](https://badge.waffle.io/apowers313/candy-wrapper.png?label=ready&title=Ready)](https://waffle.io/apowers313/candy-wrapper)

@@ -9,0 +10,0 @@ <!-- [![Sauce Test Status](https://saucelabs.com/browser-matrix/apowers313.svg)](https://saucelabs.com/u/apowers313) -->

@@ -68,3 +68,3 @@ If you have never used wrappers or candy-wrapper before, this is a good place to start. It will give you an overview of what a `Wrapper` is and how you can use them for lots of different things. Reading this tutorial shouldn't take more than five minutes and will give you a new tool for testing and development.

Every time `powerObject.pow()` it added a new {@link SingleRecord} to the `historyList` `Array`. `powerObject.pow()` behaves the exact same, but the `Wrapper` allows us to look at what happened every time it was called.
Every time `powerObject.pow()` it added a new {@link Operation} to the `historyList` `Array`. `powerObject.pow()` behaves the exact same, but the `Wrapper` allows us to look at what happened every time it was called.

@@ -87,3 +87,3 @@ That's one way of looking at the calls to `powerObject.pow()`, but it's not very easy to read. Here is another way of checking out the history of `powerObject.pow()`:

The second thing that's going on is the use of the `expectReturn()` method. Every {@link SingleRecord} in the `historyList` has a set of expectation methods on it, allowing you to check whether your expectations for that call have been met. The expectations return `true` or `false` depending on whether the expectation was met. You can use these expectations with your favorite assertion library, like [Chai](http://chaijs.com/). Or if you want to throw an `Error` when expectations aren't met, you can do this:
The second thing that's going on is the use of the `expectReturn()` method. Every {@link Operation} in the `historyList` has a set of expectation methods on it, allowing you to check whether your expectations for that call have been met. The expectations return `true` or `false` depending on whether the expectation was met. You can use these expectations with your favorite assertion library, like [Chai](http://chaijs.com/). Or if you want to throw an `Error` when expectations aren't met, you can do this:

@@ -115,3 +115,3 @@ ``` js

That's just the tip of the iceberg -- there are all kinds of {@link Filter Filters} and {@link SingleRecord expectations} that you can play around with. Before you start experimenting more, it is worth pointing out that there is a pattern to how the expectations and filters are named.
That's just the tip of the iceberg -- there are all kinds of {@link Filter Filters} and {@link Operation expectations} that you can play around with. Before you start experimenting more, it is worth pointing out that there is a pattern to how the expectations and filters are named.

@@ -150,5 +150,16 @@ * Return - the return value from a function or property get.

.triggerAlways()
.expectCallArgs(Match.type(Number))
.expectCallArgs(Match.type("number"))
```
## Configuring a Wrapper
There are three things going on in the example above: first, we have created a trigger that
always executes; second, we expect certain arguments when the function is called; and third we
have use the `Match.type` to say that we should be matching all types of `Numbers`, not just a single number value.
Now if we call our function, here is its behavior:
``` js
powerObject.pow(3); // returns 9
powerObject.pow("something"); // throws an ExpectError
```
That's it! From here you should be able to use candy-wrapper to monitor and / or modify the behavior of your functions and properties. If you have any questions, feel free to submit an [issue on GitHub](https://github.com/apowers313/candy-wrapper/issues).

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc