Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
feat: add pager support on feed.browse
Browse files Browse the repository at this point in the history
  • Loading branch information
oureta committed Feb 17, 2016
1 parent 4d82201 commit b76a657
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
9 changes: 8 additions & 1 deletion dist/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,12 @@ function browse() {
var args = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];

return (0, _fetch.get)('feed', args, config).then(_fetch.postProcess);
return (0, _fetch.get)('feed', args, config).then(function (response) {
return response.json();
}).then(function (responseJSON) {
return Promise.resolve({
success: responseJSON.success,
results: responseJSON
});
}).then(_fetch.postProcess);
}
5 changes: 5 additions & 0 deletions src/feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ import { get, postProcess } from './lib/fetch';

export function browse(args = {}, config = {}) {
return get('feed', args, config)
.then(response => response.json())
.then(responseJSON => Promise.resolve({
success: responseJSON.success,
results: responseJSON
}))
.then(postProcess);
}
6 changes: 3 additions & 3 deletions test-dist/feed/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ var browse = _dist.feed.browse;
(0, _mocha.describe)('feed.browse', function () {
var cookie = process.env.COOKIE;

(0, _mocha.it)('should be defined,\n return a Promise,\n and fail if no authenticated', function (done) {
(0, _mocha.it)('should be defined,\n return a Promise,\n and fail if not authenticated', function (done) {
_chai.assert.ok(browse);
_chai.assert.typeOf(browse(), 'Promise');
(0, _utils.shouldFail)(browse(), done);
});

(0, _mocha.it)('should succeed if authenticated', function (done) {
(0, _utils.shouldSucceed)(browse({}, { cookie: cookie }), function (feeds) {
_chai.assert.isArray(feeds);
(0, _utils.shouldSucceed)(browse({ _limit: 10, _from: 80 }, { cookie: cookie }), function (response) {
_chai.assert.isArray(response.results);
}, done);
});
});
8 changes: 4 additions & 4 deletions test/feed/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('feed.browse', () => {
it(
`should be defined,
return a Promise,
and fail if no authenticated`,
and fail if not authenticated`,
done => {
assert.ok(browse);
assert.typeOf(browse(), 'Promise');
Expand All @@ -23,9 +23,9 @@ describe('feed.browse', () => {
`should succeed if authenticated`,
done => {
shouldSucceed(
browse({}, { cookie }),
feeds => {
assert.isArray(feeds);
browse({ _limit: 10, _from: 80 }, { cookie }),
response => {
assert.isArray(response.results);
},
done
);
Expand Down

0 comments on commit b76a657

Please sign in to comment.