Skip to content

Commit

Permalink
Remove typeof Proxy check in test/should.js
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Jan 24, 2024
1 parent 89c5b43 commit f4eeb05
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions test/should.js
Original file line number Diff line number Diff line change
Expand Up @@ -3114,18 +3114,16 @@ describe('should', function() {
false.should.be.extensible;
}, 'expected false to be extensible');

if (typeof Proxy === 'function') {
var proxy = new Proxy({}, {
isExtensible: function() {
throw new TypeError();
}
});
var proxy = new Proxy({}, {
isExtensible: function() {
throw new TypeError();
}
});

err(function() {
// .extensible should not suppress errors, thrown in proxy traps
proxy.should.be.extensible;
}, { name: 'TypeError' });
}
err(function() {
// .extensible should not suppress errors, thrown in proxy traps
proxy.should.be.extensible;
}, { name: 'TypeError' });
});

it('sealed', function() {
Expand Down Expand Up @@ -3162,21 +3160,19 @@ describe('should', function() {
false.should.not.be.sealed;
}, 'expected false to not be sealed');

if (typeof Proxy === 'function') {
var proxy = new Proxy({}, {
ownKeys: function() {
throw new TypeError();
}
});
var proxy = new Proxy({}, {
ownKeys: function() {
throw new TypeError();
}
});

// Object.isSealed will call ownKeys trap only if object is not extensible
Object.preventExtensions(proxy);
// Object.isSealed will call ownKeys trap only if object is not extensible
Object.preventExtensions(proxy);

err(function() {
// .sealed should not suppress errors, thrown in proxy traps
proxy.should.be.sealed;
}, { name: 'TypeError' });
}
err(function() {
// .sealed should not suppress errors, thrown in proxy traps
proxy.should.be.sealed;
}, { name: 'TypeError' });
});

it('frozen', function() {
Expand Down Expand Up @@ -3213,20 +3209,18 @@ describe('should', function() {
false.should.not.be.frozen;
}, 'expected false to not be frozen');

if (typeof Proxy === 'function') {
var proxy = new Proxy({}, {
ownKeys: function() {
throw new TypeError();
}
});
var proxy = new Proxy({}, {
ownKeys: function() {
throw new TypeError();
}
});

// Object.isFrozen will call ownKeys trap only if object is not extensible
Object.preventExtensions(proxy);
// Object.isFrozen will call ownKeys trap only if object is not extensible
Object.preventExtensions(proxy);

err(function() {
// .frozen should not suppress errors, thrown in proxy traps
proxy.should.be.frozen;
}, { name: 'TypeError' });
}
err(function() {
// .frozen should not suppress errors, thrown in proxy traps
proxy.should.be.frozen;
}, { name: 'TypeError' });
});
});

0 comments on commit f4eeb05

Please sign in to comment.