From 065f1807eb232395d2a80670da558713a876b8e9 Mon Sep 17 00:00:00 2001 From: Turner Jabbour Date: Thu, 3 Sep 2020 23:09:08 -0600 Subject: [PATCH] doc: add example for test structure --- doc/guides/writing-tests.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index 0aa4cb8221f278..189f59c8d3237e 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: