Skip to content

Instantly share code, notes, and snippets.

@NickHeiner
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save NickHeiner/c096151731f31adc8e22 to your computer and use it in GitHub Desktop.

Select an option

Save NickHeiner/c096151731f31adc8e22 to your computer and use it in GitHub Desktop.
// Some setup code omitted for brevity
nock('https://our-backend-service.opower.it')
.post('/endpoint/we/depend/on')
// Make your test more interesting by declaring which headers you care about
// Nock lets you declare matchers on many aspects of the request
.matchHeader('Content-type', 'application/json')
.reply(200, function(uri, requestBody) {
t.deepEqual(
requestBody,
expectedRequestBody,
'request is made with the right body'
);
return theResponseWeExpect;
});
let response = yield request.get('https://localhost:3000/ei/x/demo'),
navText = getNavText(response),
expectedNavEntryItems = [
'Home',
'Demo',
'My Energy Use',
'My Plan',
'Ways to Save'
];
t.equal(
navText.length,
expectedNavEntryItems.length,
'has the right number of nav entries'
);
t.deepEqual(navText, expectedNavEntryItems, 'has the right nav on the page');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment