Skip to content

Commit

Permalink
initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thlorenz committed Jun 7, 2013
1 parent ebb8220 commit 7407144
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -12,7 +12,10 @@
},
"homepage": "https://github.com/thlorenz/parse-link-header",
"dependencies": {},
"devDependencies": {},
"devDependencies": {
"tape": "~1.0.3",
"tap": "~0.4.3"
},
"keywords": [],
"author": {
"name": "Thorsten Lorenz",
Expand Down
27 changes: 27 additions & 0 deletions test/parse-link-header.js
@@ -0,0 +1,27 @@
'use strict';
/*jshint asi: true */

var test = require('tape').test
var query = require('..')

var link =
'<https://api.github.com/user/9287/repos?client_id=1&client_secret=2&page=2&per_page=100>; rel="next", ' +
'<https://api.github.com/user/9287/repos?client_id=1&client_secret=2&page=3&per_page=100>; rel="last"'

test('querying a proper web link', function (t) {
var res = query(link)
t.deepEqual(
query(link)
, { next:
{ link: 'https://api.github.com/user/9287/repos?client_id=1&client_secret=2&page=2&per_page=100',
page: '2',
perPage: '100' },
last:
{ link: ' https://api.github.com/user/9287/repos?client_id=1&client_secret=2&page=3&per_page=100',
page: '3',
perPage: '100' } }
, 'parses out link, page and perPage for next and last'
)
t.end()

})

0 comments on commit 7407144

Please sign in to comment.