Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
unexpected-sinon
Advanced tools
This module extends the [Unexpected](https://github.com/sunesimonsen/unexpected) assertion library with integration for the [Sinonjs](http://sinonjs.org/) mocking library.
This module extends the Unexpected assertion library with integration for the Sinonjs mocking library.
expect(spy, "was called twice");
expect(spy, 'was called with', { foo: 'bar' }, 'baz', sinon.match.truthy);
expect(obj.spy, 'was always called on', obj);
Install it with NPM or add it to your package.json
:
$ npm install unexpected unexpected-sinon
Then:
var expect = require('unexpected').clone();
expect.installPlugin(require('unexpected-sinon'));
Include the unexpected.js
found at the lib directory of this
repository.
<script src="sinon.js"></script>
<script src="unexpected.js"></script>
<script src="unexpected-sinon.js"></script>
this will expose the expect function under the following namespace:
var expect = weknowhow.expect.clone();
expect.installPlugin(weknowhow.unexpectedSinon);
Include the library with RequireJS the following way:
define(['unexpected', 'unexpected-sinon'], funtion (unexpected, unexpectedSinon) {
var expect = unexpected.clone();
expect.installPlugin(unexpectedSinon);
// Your code
});
Because Sinon is currently not AMD compatible you will need this RequireJS configuration to make things work:
requirejs.config({
paths: {
'sinon': 'path/to/sinon'
},
shim: {
'sinon': {
deps: ['sinon'],
exports: 'sinon'
}
}
});
Passes if spy was called at least once.
expect(spy, 'was called');
Passes if spy was never called.
expect(spy, 'was not called');
Passes if spy was called once and only once.
expect(spy, 'was called once');
Passes if spy was called exactly twice.
expect(spy, 'was called twice');
Passes if spy was called exactly three times.
expect(spy, 'was called thrice');
Passes if the spy was called exactly num times.
expect(spy, 'was called times', 42);
Passes if the provided spies where called in the specified order.
expect([spy0, spy1, spy2], 'given call order');
Passes if the spy was ever called with obj as its this value.
expect(obj.spy, 'was called on', obj);
Passes if the spy was always called with obj as its this value.
expect(obj.spy, 'was always called on', obj);
Passes if the spy was called with the provided arguments.
expect(spy, 'was called with', { foo: 'bar' }, 'baz', sinon.match.truthy);
Passes if the spy was always called with the provided arguments.
expect(spy, 'was always called with', { foo: 'bar' }, 'baz', sinon.match.truthy);
Passes if the spy was never called with the provided arguments.
expect(spy, 'was never called with', 'bar', sinon.match.truthy);
Passes if the spy was called with the provided arguments and no others.
expect(spy, 'was called with exactly', 'foo', 'bar', sinon.match.truthy);
Passes if the spy was always called with the provided arguments and no others.
expect(spy, 'was always called with exactly', 'foo', 'bar', sinon.match.truthy);
Passes if the spy threw the given exception. The exception can be a string denoting its type, or an actual object. If only one argument is provided, the assertion passes if the spy ever threw any exception.
expect(spy, 'threw');
expect(spy, 'threw', 'TypeError');
expect(spy, 'threw', error);
Like above, only required for all calls to the spy.
expect(spy, 'always threw');
expect(spy, 'always threw', 'TypeError');
expect(spy, 'always threw', error);
spy({ foo: 'bar' }, 'baz');
spy('qux');
spy('quux');
expect(spy.args, 'to equal', [
[{ foo: 'bar' }, 'baz'],
['qux'],
['quux']
]);
expect(spy.args[1], 'to equal', ['qux']);
expect(spy.args, 'to have properties', {
0: [{ foo: 'bar' }, 'baz'],
2: ['quux']
});
v5.1.0 (2015-02-14)
FAQs
This module extends the [Unexpected](https://github.com/unexpectedjs/unexpected) assertion library with integration for the [Sinonjs](http://sinonjs.org/) mocking library.
The npm package unexpected-sinon receives a total of 6,170 weekly downloads. As such, unexpected-sinon popularity was classified as popular.
We found that unexpected-sinon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.