diff --git a/.eslintrc b/.eslintrc index 4adf476..54cc528 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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, diff --git a/lib/client.js b/lib/client.js index a5f5b61..9df0f07 100644 --- a/lib/client.js +++ b/lib/client.js @@ -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); diff --git a/test/client.js b/test/client.js index 6a9e875..84e3d4d 100644 --- a/test/client.js +++ b/test/client.js @@ -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$/); + }); }); });