Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Merge 2db8241 into 567d28b
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Urai (@uraway_) committed Jun 23, 2016
2 parents 567d28b + 2db8241 commit 5fe8423
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/blog.coffee
Expand Up @@ -167,15 +167,19 @@ class Blog
# GET CollectionURI (/<username>/<blog_id>/atom/entry)
# params:
# options:
# - pageId: page id.
# callback:
# - err: error
# - res: response
# returns:
# Promise
index: (options, callback) ->
callback = options unless callback?
method = 'get'
path = "/#{@_username}/#{@_blogId}/atom/entry"
if options? and options.pageId?
path = "/#{@_username}/#{@_blogId}/atom/entry?page=#{options.pageId}"
else
callback = options unless callback?
path = "/#{@_username}/#{@_blogId}/atom/entry"
statusCode = 200
@_request { method, path, statusCode }, callback

Expand Down
8 changes: 4 additions & 4 deletions test/blog.coffee
Expand Up @@ -196,19 +196,19 @@ describe 'blog', ->
blogId: 'blog id'
apiKey: 'api key'

describe 'all options', ->
describe 'no options', ->
it 'works', ->
@blog.index {}, -> null
args = @request.firstCall.args[0]
assert args.method is 'get'
assert args.path is '/username/blog id/atom/entry'

describe 'callback only', ->
describe 'pageId options', ->
it 'works', ->
@blog.index -> null
@blog.index { pageId: 123 }, -> null
args = @request.firstCall.args[0]
assert args.method is 'get'
assert args.path is '/username/blog id/atom/entry'
assert args.path is '/username/blog id/atom/entry?page=123'

describe '_request', ->
describe 'request succeed', ->
Expand Down

0 comments on commit 5fe8423

Please sign in to comment.