From fda2450fa07d7fb89d13d05e06849e02dada01ea Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 8 Nov 2018 00:04:44 -0500 Subject: [PATCH] tests: replace deprecated assert.deepEqual with deep-equal --- package.json | 1 + test/cookieParser.js | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index c304305..7f3f670 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "cookie-signature": "1.0.6" }, "devDependencies": { + "deep-equal": "1.0.1", "eslint": "4.19.1", "eslint-config-standard": "11.0.0", "eslint-plugin-import": "2.14.0", diff --git a/test/cookieParser.js b/test/cookieParser.js index 663f8bd..2e5a979 100644 --- a/test/cookieParser.js +++ b/test/cookieParser.js @@ -1,6 +1,7 @@ var assert = require('assert') var cookieParser = require('..') +var deepEqual = require('deep-equal') var http = require('http') var request = require('supertest') var signature = require('cookie-signature') @@ -158,7 +159,7 @@ describe('cookieParser.JSONCookie(str)', function () { }) it('should return object for JSON cookie string', function () { - assert.deepEqual(cookieParser.JSONCookie('j:{"foo":"bar"}'), { foo: 'bar' }) + deepEqual(cookieParser.JSONCookie('j:{"foo":"bar"}'), { foo: 'bar' }) }) it('should return undefined on invalid JSON', function () { @@ -216,18 +217,18 @@ describe('cookieParser.signedCookie(str, secret)', function () { describe('cookieParser.signedCookies(obj, secret)', function () { it('should ignore non-signed strings', function () { - assert.deepEqual(cookieParser.signedCookies({}, 'keyboard cat'), {}) - assert.deepEqual(cookieParser.signedCookies({ foo: 'bar' }, 'keyboard cat'), {}) + deepEqual(cookieParser.signedCookies({}, 'keyboard cat'), {}) + deepEqual(cookieParser.signedCookies({ foo: 'bar' }, 'keyboard cat'), {}) }) it('should include tampered strings as false', function () { - assert.deepEqual(cookieParser.signedCookies({ foo: 's:foobaz.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' }, 'keyboard cat'), { + deepEqual(cookieParser.signedCookies({ foo: 's:foobaz.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' }, 'keyboard cat'), { foo: false }) }) it('should include unsigned strings', function () { - assert.deepEqual(cookieParser.signedCookies({ foo: 's:foobar.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' }, 'keyboard cat'), { + deepEqual(cookieParser.signedCookies({ foo: 's:foobar.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' }, 'keyboard cat'), { foo: 'foobar' }) }) @@ -237,8 +238,8 @@ describe('cookieParser.signedCookies(obj, secret)', function () { foo: 's:foobar.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' } - assert.deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: 'foobar' }) - assert.deepEqual(obj, {}) + deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: 'foobar' }) + deepEqual(obj, {}) }) it('should remove tampered strings from original object', function () { @@ -246,8 +247,8 @@ describe('cookieParser.signedCookies(obj, secret)', function () { foo: 's:foobaz.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' } - assert.deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: false }) - assert.deepEqual(obj, {}) + deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: false }) + deepEqual(obj, {}) }) it('should leave unsigned string in original object', function () { @@ -256,8 +257,8 @@ describe('cookieParser.signedCookies(obj, secret)', function () { foo: 's:foobar.N5r0C3M8W+IPpzyAJaIddMWbTGfDSO+bfKlZErJ+MeE' } - assert.deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: 'foobar' }) - assert.deepEqual(obj, { fizz: 'buzz' }) + deepEqual(cookieParser.signedCookies(obj, 'keyboard cat'), { foo: 'foobar' }) + deepEqual(obj, { fizz: 'buzz' }) }) describe('when secret is an array', function () { @@ -267,7 +268,7 @@ describe('cookieParser.signedCookies(obj, secret)', function () { fizz: 's:foobar.JTCAgiMWsnuZpN3mrYnEUjXlGxmDi4POCBnWbRxse88' } - assert.deepEqual(cookieParser.signedCookies(obj, [ 'keyboard cat', 'nyan cat' ]), { + deepEqual(cookieParser.signedCookies(obj, [ 'keyboard cat', 'nyan cat' ]), { buzz: 'foobar', fizz: 'foobar' })