Comparing version 2.1.0 to 2.1.1
@@ -84,7 +84,8 @@ /** | ||
return new Resource(descriptor, this._options.requestOptions); | ||
}.bind(this)) | ||
.catch(function() { | ||
delete this._descriptorCache[uri]; | ||
throw new Error('Unable to get descriptor for uri "' + uri + '"'); | ||
}.bind(this)); | ||
this._descriptorCache[uri].catch(function() { | ||
delete this._descriptorCache[uri]; | ||
}); | ||
return this._descriptorCache[uri]; | ||
@@ -91,0 +92,0 @@ }; |
@@ -61,6 +61,7 @@ define(['./uritemplate', './xhr'], function(UriTemplate, xhr) { | ||
data = data || {}; | ||
options = options || {}; | ||
var selfConn = this.getConnection({ name: 'self', data: params }); | ||
return xhr(extend(this._requestOptions, options, { | ||
return xhr(extend({}, this._requestOptions, options, { | ||
url: selfConn, | ||
@@ -67,0 +68,0 @@ method: method, |
{ | ||
"name": "be-hippo", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A PropositionH hypermedia consumer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -260,4 +260,33 @@ define(['chai-as-promised', 'lib/client', 'lib/resource'], function(chaiAsPromised, Client, Resource) { | ||
}); | ||
describe('when a shortname walk 404s', function() { | ||
var links = { | ||
root: { | ||
_links: { | ||
self: { href: '/v1' }, | ||
foo: { href: '/v1/foo{?user}' } | ||
} | ||
}, | ||
foo: { | ||
_links: { | ||
self: { href: '/v1/foo{?user}' } | ||
} | ||
} | ||
}; | ||
var responses = { | ||
root: [200, { "Content-Type": "application/json" }, JSON.stringify(links.root)], | ||
foo: [404, { "Content-Type": "text/plain" }, ''], | ||
}; | ||
it('returns an "Unable to get descriptor" error', function() { | ||
var client = new Client('/v1'); | ||
server.respondWith('OPTIONS', '/v1', responses.root); | ||
server.respondWith('OPTIONS', '/v1/foo', responses.foo); | ||
return expect(client.walk('foo')).to.be.rejectedWith(new RegExp('Unable to get descriptor for uri "/v1/foo"')); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -619,3 +619,50 @@ define(['chai-as-promised', 'lib/resource'], function(chaiAsPromised, Resource) { | ||
}); | ||
describe('when multiple requests are made with the same root options', function() { | ||
var server; | ||
var descriptor = { | ||
_links: { | ||
self: { | ||
href: '/v1/foo{?baz}' | ||
} | ||
} | ||
}; | ||
var otherDescriptor = { | ||
_links: { | ||
self: { | ||
href: '/v1/bar{?baz}' | ||
} | ||
} | ||
}; | ||
beforeEach(function() { | ||
server = sinon.fakeServer.create(); | ||
server.autoRespond = true; | ||
}); | ||
afterEach(function() { | ||
server.restore(); | ||
server = null; | ||
}); | ||
it('does not modify the root options object', function() { | ||
var options = { headers: { foo: 'bar' } }; | ||
var resource = new Resource(descriptor, options); | ||
var resourceB = new Resource(otherDescriptor, options); | ||
server.respondWith('GET', '/v1/foo', function(req) { | ||
expect(req.requestHeaders.foo).to.equal('baz'); | ||
req.respond(200, { "Content-Type": "text/plain" }, ''); | ||
}); | ||
server.respondWith('GET', '/v1/bar', function(req) { | ||
expect(req.requestHeaders.foo).to.equal('bar'); | ||
req.respond(200, { "Content-Type": "text/plain" }, ''); | ||
}); | ||
return resource.get({}, { headers: { foo: 'baz' } }) | ||
.then(function() { return resourceB.get(); }); | ||
}); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77336
1971