Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/petejohanson/chai-hy-res
Chai assertions for HyRes
https://github.com/petejohanson/chai-hy-res
Last synced: 1 day ago
JSON representation
Chai assertions for HyRes
- Host: GitHub
- URL: https://github.com/petejohanson/chai-hy-res
- Owner: petejohanson
- License: mit
- Created: 2015-05-27T03:08:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-27T06:22:11.000Z (over 9 years ago)
- Last Synced: 2024-11-07T06:43:23.157Z (8 days ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chai-hy-res [![Build Status](https://travis-ci.org/petejohanson/chai-hy-res.svg?branch=master)](https://travis-ci.org/petejohanson/chai-hy-res)
A [ChaiJs](http://chaijs.com/) plugin for making assertions about [hy-res](https://github.com/petejohanson/hy-res)
## Installation
### NPM
chai-hy-res is available via NPM. To install:
$ npm install --save-dev chai-hy-res
## Setup
```javascript
var chai = require('chai');
chai.use(require('chai-hy-res'));
```## Usage
### Resource State Assertions
There are several assertions about the state of a `hy-res` resource being
resolved or unresolved.Asserting an unresolved resource:
```javascript
expect(res.$followOne('next')).to.be.an.unresolved.resource;
```For asserting resolved resource, it is often helpful to use the plugin in
combination with [chai-as-promised](http://chaijs.com/plugins/chai-as-promised):```
expect(res.$followOne('next').$promise).to.eventually.be.a.resolved.resource;
```### Link Assertions
You can assert on the presence and properties of links in the resource as well:
```javascript
expect(res).to.have.link('next').with.property('href', '/posts/123');
```Asserting on the absense of a link works as well:
```javascript
expect(res).to.not.have.link('prev');
```