From 6971bf5f577d9d8faf0992ea42a646be509219a6 Mon Sep 17 00:00:00 2001 From: Harshit Agrawal <94462364+harshit-bs@users.noreply.github.com> Date: Sun, 11 Sep 2022 15:44:05 +0530 Subject: [PATCH] Fix #3361 expect.cookie always returning undefined value (#3367) --- lib/api/expect/cookie.js | 10 +--------- test/lib/nocks.js | 12 +++++------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/api/expect/cookie.js b/lib/api/expect/cookie.js index e2b080c058..a34f66749d 100644 --- a/lib/api/expect/cookie.js +++ b/lib/api/expect/cookie.js @@ -51,15 +51,7 @@ class ExpectCookie extends BaseExpect { if (!result.value) { return this.reject(new NotFoundError(`no cookie "${this.cookieName}"${domainStr} was found`)); } - if (result && result.value) { - if (Array.isArray(result.value)) { - this.resultValue = result.value.length > 0 ? result.value[0].value : null; - } else { - this.resultValue = result.value.value; - } - } else { - this.resultValue = {}; - } + this.resultValue = result ? result.value : {}; return this.resolve(this.resultValue); }) diff --git a/test/lib/nocks.js b/test/lib/nocks.js index c673247101..5bd6696bb8 100644 --- a/test/lib/nocks.js +++ b/test/lib/nocks.js @@ -474,13 +474,11 @@ module.exports = { .reply(200, { status: 0, state: 'success', - value: [ - { - domain: 'cookie-domain', - name: name, - value: value - } - ] + value : { + domain: 'cookie-domain', + name: name, + value: value + } }); return this;