| 1 |
describe('Object.setPrototypeOf(o, p)', function () { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
it('changes prototype to regular objects', function () { |
| 5 |
var obj = { a: 123 }; |
| 6 |
expect(obj instanceof Object).to.equal(true); |
| 7 |
// sham requires assignment to work cross browser |
| 8 |
obj = Object.setPrototypeOf(obj, null); |
| 9 |
expect(obj instanceof Object).to.equal(false); |
| 10 |
expect(obj.a).to.equal(123); |
| 11 |
}); |
| 12 |
|
| 13 |
it('changes prototype to null objects', function () { |
| 14 |
var obj = Object.create(null); |
| 15 |
obj.a = 456; |
| 16 |
expect(obj instanceof Object).to.equal(false); |
| 17 |
expect(obj.a).to.equal(456); |
| 18 |
// sham requires assignment to work cross browser |
| 19 |
obj = Object.setPrototypeOf(obj, { b: 789 }); |
| 20 |
expect(obj instanceof Object).to.equal(true); |
| 21 |
expect(obj.a).to.equal(456); |
| 22 |
expect(obj.b).to.equal(789); |
| 23 |
}); |
| 24 |
}); |