node-query/node_modules/es6-shim/test-sham/set-prototype-of.js

26 lines
780 B
JavaScript
Raw Normal View History

2015-01-28 15:33:44 -05:00
/*global expect */
2014-10-28 14:36:39 -04:00
describe('Object.setPrototypeOf(o, p)', function () {
2015-01-28 15:33:44 -05:00
'use strict';
2014-10-28 14:36:39 -04:00
it('changes prototype to regular objects', function () {
var obj = {a: 123};
2015-01-28 15:33:44 -05:00
expect(obj).to.be.an.instanceOf(Object);
2014-10-28 14:36:39 -04:00
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, null);
2015-01-28 15:33:44 -05:00
expect(obj).not.to.be.an.instanceOf(Object);
2014-10-28 14:36:39 -04:00
expect(obj.a).to.equal(123);
});
it('changes prototype to null objects', function () {
var obj = Object.create(null);
obj.a = 456;
2015-01-28 15:33:44 -05:00
expect(obj).not.to.be.an.instanceOf(Object);
2014-10-28 14:36:39 -04:00
expect(obj.a).to.equal(456);
// sham requires assignment to work cross browser
obj = Object.setPrototypeOf(obj, {});
2015-01-28 15:33:44 -05:00
expect(obj).to.be.an.instanceOf(Object);
2014-10-28 14:36:39 -04:00
expect(obj.a).to.equal(456);
});
});