Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
690 bytes
|
Rev | Line | |
---|
[6a3a178] | 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 | })
|
---|
Note:
See
TracBrowser
for help on using the repository browser.