deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Support the Response object in assertObjectMatch

Open oles opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe.

I'm creating some tests for a server handler, and assertObjectMatch didn't work as expected on the responses.

Describe the solution you'd like

That

assertObjectMatch(new Response(), { status: 200 });
assertObjectMatch(new Response(null, { status: 400, statusText: "Not Found" }), { status: 400, statusText: "Not Found" });

would work.

Describe alternatives you've considered

The Response object does not have enumerable properties, so there's no elegant way to convert it into a plain object.

An alternative is to map the values manually:

const response = new Response()

assertObjectMatch(
    {
        status: response.status
    },
    {
        status: 200
    }
)

oles avatar May 09 '22 14:05 oles