summaryrefslogtreecommitdiff
path: root/doc/guides/writing-tests.md
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-04-22 15:22:40 +0300
committerVse Mozhet Byt <vsemozhetbyt@gmail.com>2017-04-25 00:06:39 +0300
commit6ee6aaefa12206335954f8c5ecb50d53125325fd (patch)
tree7e028b196b36552c3befaeee5c2b17960d84f204 /doc/guides/writing-tests.md
parentb4fea2a3d62da5e2e3f90d7f2109f02f927f7174 (diff)
downloadandroid-node-v8-6ee6aaefa12206335954f8c5ecb50d53125325fd.tar.gz
android-node-v8-6ee6aaefa12206335954f8c5ecb50d53125325fd.tar.bz2
android-node-v8-6ee6aaefa12206335954f8c5ecb50d53125325fd.zip
doc: add no-var, prefer-const in doc eslintrc
PR-URL: https://github.com/nodejs/node/pull/12563 Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Diffstat (limited to 'doc/guides/writing-tests.md')
-rw-r--r--doc/guides/writing-tests.md23
1 files changed, 11 insertions, 12 deletions
diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md
index 70690e2fda..3cb87623ae 100644
--- a/doc/guides/writing-tests.md
+++ b/doc/guides/writing-tests.md
@@ -141,22 +141,22 @@ this with a real test from the test suite.
```javascript
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
+require('../common');
+const assert = require('assert');
+const http = require('http');
-var request = 0;
-var response = 0;
+let request = 0;
+let response = 0;
process.on('exit', function() {
assert.equal(request, 1, 'http server "request" callback was not called');
assert.equal(response, 1, 'http request "response" callback was not called');
});
-var server = http.createServer(function(req, res) {
+const server = http.createServer(function(req, res) {
request++;
res.end();
}).listen(0, function() {
- var options = {
+ const options = {
agent: null,
port: this.address().port
};
@@ -172,14 +172,13 @@ This test could be greatly simplified by using `common.mustCall` like this:
```javascript
'use strict';
-var common = require('../common');
-var assert = require('assert');
-var http = require('http');
+const common = require('../common');
+const http = require('http');
-var server = http.createServer(common.mustCall(function(req, res) {
+const server = http.createServer(common.mustCall(function(req, res) {
res.end();
})).listen(0, function() {
- var options = {
+ const options = {
agent: null,
port: this.address().port
};