Skip to content

Commit

Permalink
fix: extensibility check and unhandled rejection warnings
Browse files Browse the repository at this point in the history
* fix extensibility check

* add tests for sealed and non-extensible objects

* remove unhandled rejection warnings
  • Loading branch information
shvaikalesh authored and meeber committed Sep 6, 2017
1 parent 96ad468 commit 04d6da6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FakeMap.prototype = {
return key[this._key];
},
set: function setMap(key, value) {
if (!Object.isFrozen(key)) {
if (Object.isExtensible(key)) {
Object.defineProperty(key, this._key, {
value: value,
configurable: true,
Expand Down
14 changes: 14 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,20 @@ describe('Generic', function () {
'eql({ foo: 1, bar: -> }, { foo: 1, bar: <- }) === true');
});

it('returns true with non-extensible objects', function () {
var objectA = Object.preventExtensions({ foo: 1 });
var objectB = Object.preventExtensions({ foo: 1 });
assert(eql(objectA, objectB) === true,
'eql(Object.preventExtensions({ foo: 1 }), Object.preventExtensions({ foo: 1 })) === true');
});

it('returns true with sealed objects', function () {
var objectA = Object.seal({ foo: 1 });
var objectB = Object.seal({ foo: 1 });
assert(eql(objectA, objectB) === true,
'eql(Object.seal({ foo: 1 }), Object.seal({ foo: 1 })) === true');
});

it('returns true with frozen objects', function () {
var objectA = Object.freeze({ foo: 1 });
var objectB = Object.freeze({ foo: 1 });
Expand Down
11 changes: 10 additions & 1 deletion test/new-ecmascript-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,23 @@ describe('ES2015 Specific', function () {
assert(eql(promiseResolve, promiseResolve), 'eql(promiseResolve, promiseResolve)');
assert(eql(promiseReject, promiseReject), 'eql(promiseReject, promiseReject)');
assert(eql(promisePending, promisePending), 'eql(promisePending, promisePending)');

promiseReject.catch(function () {});
});


it('returns false for different promises', function () {
assert(eql(Promise.resolve(), Promise.resolve()) === false,
'eql(Promise.resolve(), Promise.resolve()) === false');
assert(eql(Promise.reject(), Promise.reject()) === false,

var promiseRejectA = Promise.reject();
var promiseRejectB = Promise.reject();
assert(eql(promiseRejectA, promiseRejectB) === false,
'eql(Promise.reject(), Promise.reject()) === false');

promiseRejectA.catch(function () {});
promiseRejectB.catch(function () {});

assert(eql(new Promise(emptyFunction), new Promise(emptyFunction)) === false,
'eql(new Promise(emptyFunction), new Promise(emptyFunction)) === false');
});
Expand Down

0 comments on commit 04d6da6

Please sign in to comment.