2014-03-15 02:10:50 +04:00
|
|
|
/*globals describe, beforeEach, afterEach, it*/
|
2014-06-05 01:26:03 +04:00
|
|
|
/*jshint expr:true*/
|
|
|
|
var nock = require('nock'),
|
2014-03-15 02:10:50 +04:00
|
|
|
should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
testUtils = require('../utils'),
|
|
|
|
xmlrpc = require('../../server/xmlrpc'),
|
|
|
|
// storing current environment
|
|
|
|
currentEnv = process.env.NODE_ENV;
|
|
|
|
|
2014-06-05 01:26:03 +04:00
|
|
|
// To stop jshint complaining
|
|
|
|
should.equal(true, true);
|
|
|
|
|
2014-03-15 02:10:50 +04:00
|
|
|
describe('XMLRPC', function () {
|
|
|
|
var sandbox;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
// give environment a value that will ping
|
2014-06-05 01:26:03 +04:00
|
|
|
process.env.NODE_ENV = 'production';
|
2014-03-15 02:10:50 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
|
|
|
// reset the environment
|
|
|
|
process.env.NODE_ENV = currentEnv;
|
|
|
|
});
|
|
|
|
|
2014-12-10 17:03:39 +03:00
|
|
|
it('should execute two pings', function () {
|
2014-03-15 02:10:50 +04:00
|
|
|
var ping1 = nock('http://blogsearch.google.com').post('/ping/RPC2').reply(200),
|
|
|
|
ping2 = nock('http://rpc.pingomatic.com').post('/').reply(200),
|
2014-12-10 17:03:39 +03:00
|
|
|
testPost = testUtils.DataGenerator.Content.posts[2];
|
2014-03-15 02:10:50 +04:00
|
|
|
|
2014-12-10 17:03:39 +03:00
|
|
|
/*jshint unused:false */
|
2014-03-15 02:10:50 +04:00
|
|
|
|
2014-12-10 17:03:39 +03:00
|
|
|
xmlrpc.ping(testPost);
|
|
|
|
ping1.isDone().should.be.true;
|
|
|
|
ping2.isDone().should.be.true;
|
2014-03-15 02:10:50 +04:00
|
|
|
});
|
|
|
|
});
|