https://github.com/boneskull/sinon-ng
AngularJS plugin for Sinon.JS
https://github.com/boneskull/sinon-ng
Last synced: 4 months ago
JSON representation
AngularJS plugin for Sinon.JS
- Host: GitHub
- URL: https://github.com/boneskull/sinon-ng
- Owner: boneskull
- License: mit
- Archived: true
- Created: 2014-06-18T06:33:34.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-05T04:12:09.000Z (almost 9 years ago)
- Last Synced: 2025-03-22T03:36:05.723Z (11 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sinon-ng
[AngularJS](http://angularjs.org) plugin for [Sinon.JS](http://sinonjs.org).
Not much here at the moment, but if you don't care to setup mocks for `$http` calls, this is for you.
## API
These examples leverage [Mocha](http://visionmedia.github.io/mocha/), [Chai](http://chaijs.com/), and [Chai as Promised](https://github.com/domenic/chai-as-promised/).
### `fulfills()`
Causes a SinonJS stub to return a `$q` promise, fulfilled with the value you specify. Compatible with the `onCall()` functions.
Example:
```js
it('should not worry and be happy', inject(function($http) {
var foo = {
bar: function() {
return $http.post('somewhere', {stuff: 'things'});
}
},
res = {data: 'other stuff'};
sinon.stub(foo, 'bar').fulfills(res);
return expect(foo.bar()).to.eventually.equal(res);
}));
```
### `rejects()`
Causes a SinonJS stub to return a `$q` promise, rejected with the value you specify. Compatible with the `onCall()` functions.
Example:
```js
it('should go soak its head', inject(function($http) {
var foo = {
bar: function() {
return $http.post('somewhere', {stuff: 'things'});
}
},
res = {error: 'oh noes'};
sinon.stub(foo, 'bar').rejects(res);
return expect(foo.bar()).to.eventually.be.rejectedWith(res);
}));
```
## Install
```
bower install sinon-ng
```
## License
MIT
## Author
[Christopher Hiller](http://boneskull.github.io)