Skip to content

Instantly share code, notes, and snippets.

@mmmmmrob
Created September 20, 2016 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmmmmrob/97389d41ab15fa8a291a2542f89414b1 to your computer and use it in GitHub Desktop.
Save mmmmmrob/97389d41ab15fa8a291a2542f89414b1 to your computer and use it in GitHub Desktop.
wanted expectations on canned server
'use strict';
var canned = require('canned');
var http = require('http');
var opts = { logger: process.stdout };
var can = canned('/path/to/canned/response/folder', opts);
describe('Zoopla Property Listing JSON', function () {
var mock_server;
before(function () {
http.createServer(can).listen(3000)
casper.start('http://example.com/');
});
it('should Call 3rd Party when clicked', function () {
casper.thenOpen('http://example.com/something.html', function () {
this.clickLabel('Do Something Button');
});
casper.waitForUrl(/done\.html/, function () {
var request = can.lastPostTo('/api/some_resource');
var posted_body = JSON.parse(request.body);
var expected = { something: true };
expect(posted_body).to.eql(expected);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment