-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace into-stream with Readable.from #289
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||||||||||||||||
'use strict' | ||||||||||||||||||||
|
||||||||||||||||||||
const { test } = require('tap') | ||||||||||||||||||||
const Fastify = require('fastify') | ||||||||||||||||||||
const fastifyCompress = require('..') | ||||||||||||||||||||
const fsPromises = require('fs').promises | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
const { join } = require('path') | ||||||||||||||||||||
const { fetch } = require('undici') | ||||||||||||||||||||
|
||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
test('should not corrupt the file content', async (t) => { | ||||||||||||||||||||
const fastify = new Fastify() | ||||||||||||||||||||
t.teardown(() => fastify.close()) | ||||||||||||||||||||
|
||||||||||||||||||||
fastify.register(async (instance, opts) => { | ||||||||||||||||||||
await fastify.register(fastifyCompress) | ||||||||||||||||||||
instance.get('/issue', async (req, reply) => { | ||||||||||||||||||||
const longStringWithEmoji = await fsPromises.readFile(join(__dirname, './test.txt'), 'utf-8') | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
return longStringWithEmoji // <--- the file content is corrupt | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
// search for "hydra.alibaba.com" will see 2 wired question marks instead of emoji | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
}) | ||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
fastify.get('/good', async (req, reply) => { | ||||||||||||||||||||
const longStringWithEmoji = await fsPromises.readFile(join(__dirname, './test.txt'), 'utf-8') | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
return longStringWithEmoji // <--- the file content is ok | ||||||||||||||||||||
// search for "hydra.alibaba.com" will see emoji | ||||||||||||||||||||
Comment on lines
+27
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
}) | ||||||||||||||||||||
|
||||||||||||||||||||
await fastify.listen({ port: 0 }) | ||||||||||||||||||||
|
||||||||||||||||||||
const { port } = fastify.server.address() | ||||||||||||||||||||
const url = `http://localhost:${port}` | ||||||||||||||||||||
const response = await fetch(`${url}/issue`) | ||||||||||||||||||||
const response2 = await fetch(`${url}/good`) | ||||||||||||||||||||
const body = await response.text() | ||||||||||||||||||||
const body2 = await response2.text() | ||||||||||||||||||||
t.equal(body, body2) | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure number of emoji is valid |
||||||||||||||||||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note, should install
readable-stream
once and update thepackage.json
dependencies.