Comparing version 1.6.0 to 1.6.1-beta.1
# Postman UVM Changelog | ||
#### Unreleased | ||
* add ability to remove all events when only event name is provided to `bridge.off` | ||
#### 1.6.0 (May 30, 2017) | ||
@@ -4,0 +7,0 @@ * add support for removal of bridge events (internal) using `bridge.off` |
@@ -46,5 +46,9 @@ /** | ||
var e = this._events[name], | ||
i = e && this._events[name].length; | ||
i = e && e.length || 0; | ||
if (!e) { return; } | ||
if (arguments.length === 1) { | ||
return delete this._events[name]; | ||
} | ||
if (typeof listener === 'function' && (i >= 1)) { | ||
@@ -51,0 +55,0 @@ while (i >= 0) { |
{ | ||
"name": "uvm", | ||
"version": "1.6.0", | ||
"version": "1.6.1-beta.1", | ||
"description": "Universal Virtual Machine for Node and Browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -196,2 +196,55 @@ var vm = require('vm'); | ||
it('must be able to remove all events of a name', function (done) { | ||
var context = vm.createContext({ | ||
expect: expect, | ||
assertion: { | ||
one: 0, | ||
two: 0 | ||
}, | ||
__uvm_emit: function () { | ||
throw new Error('Nothing should be emitted'); | ||
}, | ||
done: function (err) { | ||
expect(err).to.not.be.ok(); | ||
expect(context).to.have.property('assertion'); | ||
expect(context.assertion).to.eql({ | ||
one: 1, | ||
two: 0 | ||
}); | ||
done(); | ||
} | ||
}); | ||
vm.runInContext(bridgeClient(), context); | ||
// run a code that listens to same event | ||
// and makes changes to a global object` | ||
vm.runInContext(` | ||
/* global assertion, done */ | ||
bridge.on('loopback', function () { | ||
expect(assertion.one).be(0); | ||
expect(assertion.two).be(0); | ||
assertion.one += 1; | ||
}); | ||
bridge.emit('loopback'); | ||
bridge.on('loopback', function () { | ||
expect(assertion.one).be(1); | ||
expect(assertion.two).be(0); | ||
assertion.one += 1; | ||
assertion.two += 1; | ||
done('error'); | ||
}); | ||
bridge.off('loopback'); // remove all events | ||
bridge.emit('loopback'); | ||
done(); | ||
`, context); | ||
}); | ||
it('must not leave behind any additional globals except `bridge` related', function (done) { | ||
@@ -198,0 +251,0 @@ var context = vm.createContext({ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
117695
1928
1