Permalink
Browse files

Add deprecation warning to maxage property

  • Loading branch information...
1 parent 69ca9b7 commit e2aedb1bff6f26147895d7ee9a19d4345c6236d9 @dougwilson dougwilson committed Aug 15, 2016
Showing with 28 additions and 1 deletion.
  1. +1 −0 lib/cookies.js
  2. +27 −1 test/cookie.js
View
@@ -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]
View
@@ -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)
@@ -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.