/* eslint-env mocha, browser */
/* global proclaim */

it('has the correct length', function() {
	proclaim.deepEqual(Object.assign.length, 2);
});

it('throws when target is not an object', function() {
	proclaim.throws(function () {
		Object.assign(null);
	}, TypeError);

	proclaim.throws(function () {
		Object.assign(undefined);
	}, TypeError);
});

it('Object properties are assigned to target in ascending index order', function () {
	proclaim.deepEqual(Object.assign({ foo: 0 }, { bar: 1 }), {
		foo: 0,
		bar: 1
	});
});

it('Ignores null and undefined sources', function () {
	proclaim.deepEqual(Object.assign({ foo: 0 }, null, undefined), { foo: 0 });

	proclaim.deepEqual(Object.assign({ foo: 0 }, null, undefined, { bar: 1 }, null), {
		foo: 0,
		bar: 1
	});
});

it('throws on null or undefined targets', function() {
	proclaim.throws(function () {
		Object.assign(null, {});
	});

	proclaim.throws(function () {
		Object.assign(undefined, {});
	});

	proclaim.throws(function () {
		Object.assign(undefined, undefined);
	});
});

it('supports multiple sources, overriding previous copies of the same property', function() {
	proclaim.deepEqual(Object.assign({foo: 0}, {bar: 1}, {bar: 2}), {
		foo: 0,
		bar: 2
	});
});

it('does not iterate prototype properties', function() {
	const Bar = function () {};
	Bar.prototype.foo = 2;
	const bar = new Bar();
	bar.baz = 1;

	proclaim.deepEqual(Object.assign({foo: 1}, bar), {
		foo: 1,
		baz: 1
	});
});

it('returns the target object', function() {
	const target = {};
	const returned = Object.assign(target, {foo: 1});
	proclaim.deepEqual(returned, target);
});

it('support `Object.create(null)` objects', function() {
	const obj = Object.create(null);
	obj.foo = true;
	proclaim.deepEqual(Object.assign({}, obj), {foo: true});
});

it('converts primitives as the target into Objects', function() {
	const target = Object.assign(true, {foo: 'bar'});
	const booleanObject = Object(true);
	booleanObject.foo = 'bar';
	proclaim.deepEqual(target, booleanObject);
});

@@ -1285,21 +1285,19 @@
 on() %7B%0A%09
-const
+var
  Bar = f
@@ -1336,21 +1336,19 @@
 o = 2;%0A%09
-const
+var
  bar = n
@@ -1491,37 +1491,35 @@
 , function() %7B%0A%09
-const
+var
  target = %7B%7D;%0A%09c
@@ -1517,21 +1517,19 @@
  = %7B%7D;%0A%09
-const
+var
  returne
@@ -1613,179 +1613,8 @@
 );%0A%0A
-it('support %60Object.create(null)%60 objects', function() %7B%0A%09const obj = Object.create(null);%0A%09obj.foo = true;%0A%09proclaim.deepEqual(Object.assign(%7B%7D, obj), %7Bfoo: true%7D);%0A%7D);%0A%0A
 it('
@@ -1676,21 +1676,19 @@
 on() %7B%0A%09
-const
+var
  target 
@@ -1729,13 +1729,11 @@
 );%0A%09
-const
+var
  boo

Add tests for ES5 version of Object.assign