| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b8511ab commit 420b3b8
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,52 +1,49 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | common.globalCheck = false; | |
| 4 | 4 | ||
| 5 | - var assert = require('assert'); | ||
| 6 | - var repl = require('repl'); | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + const repl = require('repl'); | ||
| 7 | 7 | ||
| 8 | 8 | // Create a dummy stream that does nothing | |
| 9 | 9 | const dummy = new common.ArrayStream(); | |
| 10 | 10 | ||
| 11 | 11 | function testReset(cb) { | |
| 12 | - var r = repl.start({ | ||
| 12 | + const r = repl.start({ | ||
| 13 | 13 | input: dummy, | |
| 14 | 14 | output: dummy, | |
| 15 | 15 | useGlobal: false | |
| 16 | 16 | }); | |
| 17 | 17 | r.context.foo = 42; | |
| 18 | - r.on('reset', function(context) { | ||
| 18 | + r.on('reset', common.mustCall(function(context) { | ||
| 19 | 19 | assert(!!context, 'REPL did not emit a context with reset event'); | |
| 20 | - assert.equal(context, r.context, 'REPL emitted incorrect context'); | ||
| 21 | - assert.equal(context.foo, undefined, 'REPL emitted the previous context' + | ||
| 22 | - ', and is not using global as context'); | ||
| 20 | + assert.strictEqual(context, r.context, 'REPL emitted incorrect context'); | ||
| 21 | + assert.strictEqual( | ||
| 22 | + context.foo, | ||
| 23 | + undefined, | ||
| 24 | + 'REPL emitted the previous context, and is not using global as context' | ||
| 25 | + ); | ||
| 23 | 26 | context.foo = 42; | |
| 24 | 27 | cb(); | |
| 25 | - }); | ||
| 28 | + })); | ||
| 26 | 29 | r.resetContext(); | |
| 27 | 30 | } | |
| 28 | 31 | ||
| 29 | - function testResetGlobal(cb) { | ||
| 30 | - var r = repl.start({ | ||
| 32 | + function testResetGlobal() { | ||
| 33 | + const r = repl.start({ | ||
| 31 | 34 | input: dummy, | |
| 32 | 35 | output: dummy, | |
| 33 | 36 | useGlobal: true | |
| 34 | 37 | }); | |
| 35 | 38 | r.context.foo = 42; | |
| 36 | - r.on('reset', function(context) { | ||
| 37 | - assert.equal(context.foo, 42, | ||
| 38 | - '"foo" property is missing from REPL using global as context'); | ||
| 39 | - cb(); | ||
| 40 | - }); | ||
| 39 | + r.on('reset', common.mustCall(function(context) { | ||
| 40 | + assert.strictEqual( | ||
| 41 | + context.foo, | ||
| 42 | + 42, | ||
| 43 | + '"foo" property is missing from REPL using global as context' | ||
| 44 | + ); | ||
| 45 | + })); | ||
| 41 | 46 | r.resetContext(); | |
| 42 | 47 | } | |
| 43 | 48 | ||
| 44 | - var timeout = setTimeout(function() { | ||
| 45 | - common.fail('Timeout, REPL did not emit reset events'); | ||
| 46 | - }, 5000); | ||
| 47 | - | ||
| 48 | - testReset(function() { | ||
| 49 | - testResetGlobal(function() { | ||
| 50 | - clearTimeout(timeout); | ||
| 51 | - }); | ||
| 52 | - }); | ||
| 49 | + testReset(common.mustCall(testResetGlobal)); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments