| 16 | }); |
| 17 | |
| 18 | function doAsserts(serverUrl, done) { |
| 19 | sandbox.useFakeServer(); |
| 20 | sandbox.server.respondWith(serverUrl + '/hello', [200, { "Content-Type": "application/json" }, '{ "ok": true }']); |
| 21 | sandbox.server.autoRespond = true; |
| 22 | sandbox.stub(io, "connect").returns({ on: function() {} }); |
| 23 | |
| 24 | dpd.on('test', function(){ |
| 25 | // used to force socket.io to connect |
| 26 | }); |
| 27 | |
| 28 | dpd('/hello').get(function (res, err) { |
| 29 | expect(res).to.exist; |
| 30 | expect(res.ok).to.be.true; |
| 31 | expect(io.connect.calledWith(serverUrl)).to.be.true; |
| 32 | done(); |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | it('should allow overriding server root via setBaseUrl', function(done) { |
| 37 | dpd.setBaseUrl('http://the-api-is-here.domain.api:22'); |