-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix: set reply's default charset to utf8 #3789
Changes from 1 commit
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 |
---|---|---|
|
@@ -729,6 +729,30 @@ test('non-string with content type application/json SHOULD be serialized as json | |
}) | ||
}) | ||
|
||
test('non-string with custom json\'s content-type SHOULD be serialized as json', t => { | ||
t.plan(4) | ||
|
||
const fastify = require('../..')() | ||
|
||
fastify.get('/', function (req, reply) { | ||
reply.type('application/json; version=2; ').send({ key: 'hello world!' }) | ||
}) | ||
|
||
fastify.listen({ port: 0 }, err => { | ||
t.error(err) | ||
fastify.server.unref() | ||
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. I know it is used in other tests, but could you use the 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. PTAL, but I want to know what is the difference between 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.
|
||
|
||
sget({ | ||
method: 'GET', | ||
url: 'http://localhost:' + fastify.server.address().port | ||
}, (err, response, body) => { | ||
t.error(err) | ||
t.equal(response.headers['content-type'], 'application/json; version=2; charset=utf-8') | ||
t.same(body.toString(), JSON.stringify({ key: 'hello world!' })) | ||
}) | ||
}) | ||
}) | ||
|
||
test('non-string with custom json content type SHOULD be serialized as json', t => { | ||
t.plan(16) | ||
|
||
|
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.
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.
Ooops, I missed this. I'll amend on main.
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.
Cheers @mcollina!