Skip to content

Commit

Permalink
Add test to show that sealed objects are still not extensible
Browse files Browse the repository at this point in the history
  • Loading branch information
bmomberger-bitovi committed May 1, 2017
1 parent f023cbc commit 9715a88
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion map/map-test.js
Expand Up @@ -685,4 +685,37 @@ QUnit.test("Does not attempt to redefine _data if already defined", function() {
QUnit.equal(baz.plonk, "waldo", "New computed definitions successful");
QUnit.equal(baz.baz, "thud", "Old definitions still available");

});
});

QUnit.test("redefines still not allowed on sealed objects", function() {
QUnit.expect(6);
var Bar = DefineMap.extend({seal: true}, {
baz: { value : "thud" }
});

var baz = new Bar();

try {
define(baz, {
quux: { value: "jeek" }
}, baz._define);
} catch(e) {
QUnit.ok(/object is not extensible/.test(e.message), "Sealed object throws on data property defines");
QUnit.ok(!Object.getOwnPropertyDescriptor(baz, "quux"), "nothing set on object");
QUnit.ok(!Object.getOwnPropertyDescriptor(baz._data, "quux"), "nothing set on _data");
}

try {
define(baz, {
plonk: {
get: function() {
return "waldo";
}
}
}, baz._define);
} catch(e) {
QUnit.ok(/object is not extensible/.test(e.message), "Sealed object throws on computed property defines");
QUnit.ok(!Object.getOwnPropertyDescriptor(baz, "plonk"), "nothing set on object");
QUnit.ok(!Object.getOwnPropertyDescriptor(baz._computed, "plonk"), "nothing set on _computed");
}
});

0 comments on commit 9715a88

Please sign in to comment.