Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

expose server as '.remote' property of client. Perhaps should call it…

… 'server'.
  • Loading branch information...
commit 6ccd8ca8cbf302e9dde2a9fb0f3a5311e837f8b3 1 parent ce31240
Tim Oxley authored
Showing with 16 additions and 0 deletions.
  1. +2 −0  lib/client.js
  2. +14 −0 tests/integration.js
2  lib/client.js
View
@@ -19,6 +19,7 @@ Client.prototype = new EventEmitter
// args passed to enode api calls
var addMetaInformationTo = function(self) {
return function(remote, connection) {
+ self.remote = remote
var wrappedAPI = {}
_.each(self._api, function(value, name) {
if (typeof value === 'function') {
@@ -66,6 +67,7 @@ Client.prototype.connect = function(host, callback) {
this.up.once('remote', function() {
self.up.once('up', function(remote) {
self.ready = true
+ self.remote = remote
self.emit('ready', remote, self.connection)
return callback(null, remote, self.connection)
})
14 tests/integration.js
View
@@ -3,10 +3,13 @@
var assert = require('assert')
var async = require('async')
+var _ = require('underscore')
+
var Server = require('../lib/server')
var Client = require('../lib/client')
var PORT = 5000
+
describe('handing an API', function() {
var server, client
function shutdown(done) {
@@ -244,5 +247,16 @@ describe('handing an API', function() {
})
})
+ describe('exposing remote methods on "remote" property', function() {
+ beforeEach(function(done) {
+ server = new Server({isServer: 'server'}).listen(PORT, done)
+ })
+ beforeEach(function(done) {
+ client = new Client({isClient: 'client'}).connect(PORT, done)
+ })
+ it('client exposes remote server on "remote" property', function() {
+ assert.equal(client.remote.isServer, 'server')
+ })
+ })
})
Please sign in to comment.
Something went wrong with that request. Please try again.