From 026a723b545c6b3b0c622851b7d164be2674e8a2 Mon Sep 17 00:00:00 2001 From: William Killerud Date: Wed, 15 May 2024 15:30:09 +0200 Subject: [PATCH] fix: make response toJSON return type serializable Avoid returning class type, instead returning the toJSON of css and js assets. --- lib/response.js | 4 ++-- tests/response.test.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/response.js b/lib/response.js index 4fe15ef3..53253b57 100644 --- a/lib/response.js +++ b/lib/response.js @@ -59,8 +59,8 @@ export default class PodiumClientResponse { redirect: this.redirect, content: this.content, headers: this.headers, - css: this.css, - js: this.js, + css: this.css.map((a) => a.toJSON()), + js: this.js.map((a) => a.toJSON()), }; } diff --git a/tests/response.test.js b/tests/response.test.js index 9e455135..d4a96af6 100644 --- a/tests/response.test.js +++ b/tests/response.test.js @@ -133,8 +133,8 @@ tap.test( t.same(response.toJSON(), { content: 'foo', headers: { foo: 'bar' }, - css: [css], // TODO: should we also call .toJSON on the contents of the array? - js: [js], // TODO: should we also call .toJSON on the contents of the array? + css: [css.toJSON()], + js: [js.toJSON()], redirect: { statusCode: 302, location: 'http://redirects.are.us.com',