'use strict';

var test = require('tape');
var TChannel = require('tchannel');

var AutobahnClient = require('../index.js');

test('creating AutobahnClient with new', function t(assert) {
    var c = new AutobahnClient({
        tchannel: TChannel(),
        serviceName: 'foo',
        callerName: 'foo-test',
        hostPortList: []
    });

    assert.ok(c, 'can create a client');

    assert.end();
});

test('create AutobahnClient without options', function t(assert) {
    assert.throws(function throwIt() {
        AutobahnClient();
    }, /invalid option tchannel/);

    assert.end();
});

test('create AutobahnClient without options.tchannel', function t(assert) {
    assert.throws(function throwIt() {
        AutobahnClient({});
    }, /invalid option tchannel/);

    assert.end();
});

test('create AutobahnClient with a subchannel', function t(assert) {
    assert.throws(function throwIt() {
        var tchannel = TChannel();

        AutobahnClient({
            tchannel: tchannel.makeSubChannel({
                serviceName: 'foo'
            })
        });
    }, /invalid option tchannel/);

    assert.end();
});

test('create AutobahnClient without serviceName', function t(assert) {
    assert.throws(function throwIt() {
        var tchannel = TChannel();

        AutobahnClient({
            tchannel: tchannel
        });
    }, /invalid option serviceName/);

    assert.end();
});

test('create AutobahnClient without hostPortList', function t(assert) {
    assert.throws(function throwIt() {
        var tchannel = TChannel();

        AutobahnClient({
            tchannel: tchannel,
            serviceName: 'foo'
        });
    }, /invalid option hostPortList/);

    assert.end();
});

@@ -60,24 +60,22 @@
 equire('
-tchannel
+../../
 ');%0A%0Avar
@@ -75,20 +75,21 @@
 );%0A%0Avar 
-Auto
+Hyper
 bahnClie
@@ -105,16 +105,29 @@
 ire('../
+../hyperbahn/
 index.js
@@ -146,20 +146,21 @@
 reating 
-Auto
+Hyper
 bahnClie
@@ -210,20 +210,21 @@
 c = new 
-Auto
+Hyper
 bahnClie
@@ -422,36 +422,37 @@
 ;%0A%0Atest('create 
-Auto
+Hyper
 bahnClient witho
@@ -524,36 +524,37 @@
 wIt() %7B%0A        
-Auto
+Hyper
 bahnClient();%0A  
@@ -615,36 +615,37 @@
 ;%0A%0Atest('create 
-Auto
+Hyper
 bahnClient witho
@@ -726,36 +726,37 @@
 wIt() %7B%0A        
-Auto
+Hyper
 bahnClient(%7B%7D);%0A
@@ -819,36 +819,37 @@
 ;%0A%0Atest('create 
-Auto
+Hyper
 bahnClient with 
@@ -959,36 +959,37 @@
 nel();%0A%0A        
-Auto
+Hyper
 bahnClient(%7B%0A   
@@ -1159,36 +1159,37 @@
 ;%0A%0Atest('create 
-Auto
+Hyper
 bahnClient witho
@@ -1301,36 +1301,37 @@
 nel();%0A%0A        
-Auto
+Hyper
 bahnClient(%7B%0A   
@@ -1445,20 +1445,21 @@
 'create 
-Auto
+Hyper
 bahnClie
@@ -1592,12 +1592,13 @@
     
-Auto
+Hyper
 bahn

refactor constructor to pass