From 1e6c3aba490a7e9a5d8f2bbaae8864ad631c8538 Mon Sep 17 00:00:00 2001 From: "Stanley (QXU)" Date: Sat, 30 Mar 2024 20:11:29 +0800 Subject: [PATCH] polish test case --- test/issue-288.test.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/issue-288.test.js b/test/issue-288.test.js index 8c53ea5..0971c8c 100644 --- a/test/issue-288.test.js +++ b/test/issue-288.test.js @@ -25,24 +25,23 @@ test('should not corrupt the file content', async (t) => { fastify.register(async (instance, opts) => { await fastify.register(fastifyCompress) // compression - instance.get('/issue', async (req, reply) => { + instance.get('/compress', async (req, reply) => { return twoByteUnicodeContent }) }) // no compression - fastify.get('/good', async (req, reply) => { + fastify.get('/no-compress', async (req, reply) => { return twoByteUnicodeContent }) - await fastify.listen({ port: 0 }) + const address = await fastify.listen({ port: 0 }) - const { port } = fastify.server.address() - const url = `http://localhost:${port}` - - const response = await request(`${url}/issue`) - const response2 = await request(`${url}/good`) + const response = await request(`${address}/compress`) + const response2 = await request(`${address}/no-compress`) const body = await response.body.text() const body2 = await response2.body.text() + t.equal(body.length, twoByteUnicodeContent.length) + t.equal(body2.length, twoByteUnicodeContent.length) t.equal(body, body2) })