Skip to content

Commit

Permalink
test client options initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jan 26, 2015
1 parent 6289561 commit 1d29f94
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Expand Up @@ -21,7 +21,7 @@
"no-console": 0,
"no-constant-condition": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-debugger": 1,
"no-delete-var": 2,
"no-div-regex": 0,
"no-dupe-keys": 2,
Expand Down
12 changes: 6 additions & 6 deletions lib/client.js
Expand Up @@ -4,21 +4,21 @@
var debug = require('debug')('arkivo:hydra:client');
var assert = require('assert');
var B = require('bluebird');
var joins = require('path').joins;
var join = require('path').join;
var inherits = require('util').inherits;

var HTTPClient = require('./http');

function HydraClient(sync, host) {
function HydraClient(host, sync) {
host = host || HydraClient.DEFAULT_HOST;

HTTPClient.call(this, {
create: joins(host, '/api/items'),
update: joins(host, '/api/items/:id'),
delete: joins(host, '/api/items/:id')
create: join(host, '/api/items'),
update: join(host, '/api/items/:id'),
delete: join(host, '/api/items/:id')
});

this.sync = sync;
this.sync = sync;
}

inherits(HydraClient, HTTPClient);
Expand Down
19 changes: 19 additions & 0 deletions test/client.js
Expand Up @@ -11,14 +11,33 @@ chai.use(require('sinon-chai'));
chai.use(require('chai-as-promised'));

var HydraClient = require('../lib/client');
var HTTPClient = require('../lib/http');

//var Session = require('arkivo/lib/sync').Session;
//var Subscription = arkivo.Subscription;


describe('HydraClient', function () {
var client;

beforeEach(function () { client = new HydraClient(); });

it('is a constructor function', function () {
expect(HydraClient).to.be.a('function');
expect(client).to.be.instanceOf(HydraClient);
});

it('inherits from HTTPClient', function () {
expect(client).to.be.instanceOf(HTTPClient);
});

describe('#options', function () {
it('has CRUD paths', function () {
expect(client)
.to.have.property('options')
.that.has.keys(['create', 'update', 'delete']);

expect(client.options.update).to.match(/api\/items\/:id$/);
});
});
});

0 comments on commit 1d29f94

Please sign in to comment.