Skip to content

Commit

Permalink
add tests for options.headers
Browse files Browse the repository at this point in the history
  • Loading branch information
jfromaniello committed Aug 19, 2015
1 parent 0643597 commit 7787dd7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ JWT.decode = function (jwt, options) {
header: decoded.header,
payload: payload,
signature: decoded.signature
}
};
}
return payload;
};
Expand Down
18 changes: 18 additions & 0 deletions test/set_headers.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var jwt = require('../index');
var expect = require('chai').expect;

describe('set headers', function() {

it('should add the header', function () {
var token = jwt.sign({foo: 123}, '123', { headers: { foo: 'bar' } });
var decoded = jwt.decode(token, {complete: true});
expect(decoded.header.foo).to.equal('bar');
});

it('should allow overriding headers', function () {
var token = jwt.sign({foo: 123}, '123', { headers: { alg: 'HS512' } });
var decoded = jwt.decode(token, {complete: true});
expect(decoded.header.alg).to.equal('HS512');
});

});

0 comments on commit 7787dd7

Please sign in to comment.