-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change default header to
node
(#2310)
* change default header to `node` * switch on filename, add tests
- Loading branch information
1 parent
0fde27d
commit fcc1e39
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
const { test } = require('tap') | ||
const events = require('events') | ||
const http = require('http') | ||
const undici = require('../../') | ||
const nodeBuild = require('../../undici-fetch.js') | ||
|
||
test('user-agent defaults correctly', async (t) => { | ||
const server = http.createServer((req, res) => { | ||
res.end(JSON.stringify({ userAgentHeader: req.headers['user-agent'] })) | ||
}) | ||
t.teardown(server.close.bind(server)) | ||
|
||
server.listen(0) | ||
await events.once(server, 'listening') | ||
const url = `http://localhost:${server.address().port}` | ||
const [nodeBuildJSON, undiciJSON] = await Promise.all([ | ||
nodeBuild.fetch(url).then((body) => body.json()), | ||
undici.fetch(url).then((body) => body.json()) | ||
]) | ||
|
||
t.same(nodeBuildJSON.userAgentHeader, 'node') | ||
t.same(undiciJSON.userAgentHeader, 'undici') | ||
}) |