Skip to content

Commit

Permalink
Add deprecation warning to maxage property
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Aug 15, 2016
1 parent 69ca9b7 commit e2aedb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Object.defineProperty(Cookie.prototype, 'maxage', {
get: function () { return this.maxAge },
set: function (val) { return this.maxAge = val }
});
deprecate.property(Cookie.prototype, 'maxage', '"maxage"; use "maxAge" instead')

function getPattern(name) {
if (cache[name]) return cache[name]
Expand Down
28 changes: 27 additions & 1 deletion test/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var assert = require('assert')
var cookies = require('..')

describe('new Cookie', function () {
describe('new Cookie(name, value, [options])', function () {
it('should have correct constructor', function () {
var cookie = new cookies.Cookie('foo', 'bar')
assert.equal(cookie.constructor, cookies.Cookie)
Expand Down Expand Up @@ -31,4 +31,30 @@ describe('new Cookie', function () {
new cookies.Cookie('foo', 'bar', { domain: 'example.com\n' })
}, /option domain is invalid/)
})

describe('options', function () {
describe('maxage', function () {
it('should set the .maxAge property', function () {
var cookie = new cookies.Cookie('foo', 'bar', { maxage: 86400 })
assert.equal(cookie.maxAge, 86400)
})

it('should set the .maxage property', function () {
var cookie = new cookies.Cookie('foo', 'bar', { maxage: 86400 })
assert.equal(cookie.maxage, 86400)
})
})

describe('maxage', function () {
it('should set the .maxAge property', function () {
var cookie = new cookies.Cookie('foo', 'bar', { maxAge: 86400 })
assert.equal(cookie.maxAge, 86400)
})

it('should set the .maxage property', function () {
var cookie = new cookies.Cookie('foo', 'bar', { maxAge: 86400 })
assert.equal(cookie.maxage, 86400)
})
})
})
})

0 comments on commit e2aedb1

Please sign in to comment.