summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTurner Jabbour <doubleujabbour@gmail.com>2020-09-03 23:09:08 -0600
committerMichaël Zasso <targos@protonmail.com>2021-02-02 10:50:59 +0100
commite55d3d09534c11b760d7226fb235aa7fa282b6d2 (patch)
tree4b6a86f9a47ad429b4c6b2a0e9987efaba94fe2e
parent9b9a1801baeb6378e83ca0a9cdf3677f21cebd4d (diff)
downloadnode-new-e55d3d09534c11b760d7226fb235aa7fa282b6d2.tar.gz
doc: add example for test structure
PR-URL: https://github.com/nodejs/node/pull/35046 Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
-rw-r--r--doc/guides/writing-tests.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md
index 62e058911b..0d33aabb06 100644
--- a/doc/guides/writing-tests.md
+++ b/doc/guides/writing-tests.md
@@ -109,6 +109,21 @@ case, `_`, lower case).
### **Lines 11-22**
+```js
+const server = http.createServer(common.mustCall((req, res) => {
+ res.end('ok');
+}));
+server.listen(0, () => {
+ http.get({
+ port: server.address().port,
+ headers: { 'Test': 'Düsseldorf' }
+ }, common.mustCall((res) => {
+ assert.strictEqual(res.statusCode, 200);
+ server.close();
+ }));
+});
+```
+
This is the body of the test. This test is simple, it just tests that an
HTTP server accepts `non-ASCII` characters in the headers of an incoming
request. Interesting things to notice: