Skip to content

Commit

Permalink
fix spelling of endpoint and remove multi type arugment support in fa…
Browse files Browse the repository at this point in the history
…vor of array only
  • Loading branch information
James Baxley committed Mar 19, 2016
1 parent 191d1a5 commit c72ce50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/networkLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NetworkLayer {

constructor(uri, opts = {}) {
if (!uri) {
throw new Error('A remote enpdoint is required for a newtork layer');
throw new Error('A remote endpoint is required for a newtork layer');
}

if (!isString(uri)) {
Expand All @@ -25,14 +25,12 @@ class NetworkLayer {
}

query(requests) {
let clonedRequests = [];

if (!isArray(requests)) {
clonedRequests = [requests];
} else {
clonedRequests = [...requests];
throw new Error('Requests must be an array of requests');
}

const clonedRequests = [...requests];

return Promise.all(clonedRequests.map(request => (
this._query(request).then(
result => result.json()
Expand Down
6 changes: 3 additions & 3 deletions test/networkLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('NetworkLayer', () => {
it('should throw without an endpoint', () => {
assert.throws(() => {
const networkLayer = new NetworkLayer(); // eslint-disable-line no-unused-vars
}, /A remote enpdoint is required for a newtork layer/);
}, /A remote endpoint is required for a newtork layer/);
});

it('should create an instance with a given uri', () => {
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('NetworkLayer', () => {
};

assert.eventually.deepEqual(
Swapi.query(simpleRequest),
Swapi.query([simpleRequest]),
[
{
data: {
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('NetworkLayer', () => {
getDebugName() { return 'People query'; },
};

assert.isRejected(Swapi.query(simpleRequest), /Server request for query/)
assert.isRejected(Swapi.query([simpleRequest]), /Server request for query/)
.notify(done);
});

Expand Down

0 comments on commit c72ce50

Please sign in to comment.