Testing slave resources

Although we have tested the main HAL document for an order, we are still not done. We have discovered that we need to create more HAL resources, order items, and actions. We need to write tests for them too.

The order actions

As we saw earlier, each action has been extracted to a form resource. How do form resources look?

Let's start with the /orders/:orderId/place-order-form resource. We will need a new feature for this, since accessing a form resource is a different operation from accessing the order from the consumer's point of view.

Let's create a test/get_placeOrderForm.js test suite:

'use strict'; var chai = require('chai'), expect = chai.expect, Q = require('q'); chai.use(require("sinon-chai")); chai.use(require("chai-as-promised")); ...

Get Learning Behavior-driven Development with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.