index.js (690B)
1 'use strict' 2 /* eslint-env mocha */ 3 /* eslint no-proto: 0 */ 4 var assert = require('assert') 5 var setPrototypeOf = require('..') 6 7 describe('setProtoOf(obj, proto)', function () { 8 it('should merge objects', function () { 9 var obj = { a: 1, b: 2 } 10 var proto = { b: 3, c: 4 } 11 var mergeObj = setPrototypeOf(obj, proto) 12 13 if (Object.getPrototypeOf) { 14 assert.strictEqual(Object.getPrototypeOf(obj), proto) 15 } else if ({ __proto__: [] } instanceof Array) { 16 assert.strictEqual(obj.__proto__, proto) 17 } else { 18 assert.strictEqual(obj.a, 1) 19 assert.strictEqual(obj.b, 2) 20 assert.strictEqual(obj.c, 4) 21 } 22 assert.strictEqual(mergeObj, obj) 23 }) 24 })