chai-hy-res
A ChaiJs plugin for making assertions about hy-res
Installation
NPM
chai-hy-res is available via NPM. To install:
$ npm install --save-dev chai-hy-res
Setup
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:
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:
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:
expect(res).to.have.link('next').with.property('href', '/posts/123');
Asserting on the absense of a link works as well:
expect(res).to.not.have.link('prev');