var mirrorKey = require('../mirrorkey');

describe('MirrorKey', function() {
	it('throws an exception if the passed in argument is not an object or an array', function() {
		var errorMsg = 'The first argument to mirrorKey must be a object or an array.';

		expect(function() {
			mirrorKey(null);
		}).toThrow(errorMsg);

		expect(function() {
			mirrorKey(1);
		}).toThrow(errorMsg);

		expect(function() {
			mirrorKey('bob');
		}).toThrow(errorMsg);
	});

	it('throws an exception if transformType is unknown', function() {
		expect(function() {
			mirrorKey({}, '404-transform');
		}).toThrow('Unknown value for transformType. Valid values: none, camel-case, lower-case, dashed, lower-dashed');
	});

	it('returns an empty object if the argument is an empty object', function() {
		var result = mirrorKey({});

		expect(Object.keys(result).length).toEqual(0);
	});

	it('returns an empty object if the argument is an empty array', function() {
		var result = mirrorKey([]);

		expect(Object.keys(result).length).toEqual(0);
	});

	it('adds values to each key', function() {
		var result = mirrorKey({
			MY_KEY1: null,
			MY_KEY2: null
		});

		expect(result.MY_KEY1).toEqual('MY_KEY1');
		expect(result.MY_KEY2).toEqual('MY_KEY2');
	});

	it('adds values to each key (array)', function() {
		var result = mirrorKey([
			'MY_KEY1',
			'MY_KEY2'
		]);

		expect(result.MY_KEY1).toEqual('MY_KEY1');
		expect(result.MY_KEY2).toEqual('MY_KEY2');
	});

	it('adds values in camel-case', function() {
		var result = mirrorKey(
			{
				MY_KEY1: null
			},
			'camel-case'
		);

		expect(result.MY_KEY1).toEqual('MyKey1');

		result = mirrorKey(
			[
				'MY_KEY1'
			],
			'camel-case'
		);

		expect(result.MY_KEY1).toEqual('MyKey1');
	});

	it('adds values in lower-case', function() {
		var result = mirrorKey(
			{
				MY_KEY1: null
			},
			'lower-case'
		);

		expect(result.MY_KEY1).toEqual('my_key1');

		result = mirrorKey(
			[
				'MY_KEY1'
			],
			'lower-case'
		);

		expect(result.MY_KEY1).toEqual('my_key1');
	});

	it('adds values in dashed', function() {
		var result = mirrorKey(
			{
				MY_KEY1: null
			},
			'dashed'
		);

		expect(result.MY_KEY1).toEqual('MY-KEY1');

		result = mirrorKey(
			[
				'MY_KEY1'
			],
			'dashed'
		);

		expect(result.MY_KEY1).toEqual('MY-KEY1');
	});

	it('adds values in lower-dashed', function() {
		var result = mirrorKey(
			{
				MY_KEY1: null
			},
			'lower-dashed'
		);

		expect(result.MY_KEY1).toEqual('my-key1');

		result = mirrorKey(
			[
				'MY_KEY1'
			],
			'lower-dashed'
		);

		expect(result.MY_KEY1).toEqual('my-key1');
	});
});
@@ -1513,37 +1513,32 @@
  mirrorKey(%0A%09%09%09%7B
-%0A%09%09%09%09
 MY_KEY1: null%0A%09%09
@@ -1530,28 +1530,24 @@
 Y_KEY1: null
-%0A%09%09%09
 %7D,%0A%09%09%09'camel
@@ -1622,37 +1622,32 @@
  mirrorKey(%0A%09%09%09%5B
-%0A%09%09%09%09
 'MY_KEY1'%0A%09%09%09%5D,%0A
@@ -1635,28 +1635,24 @@
 %09%09%5B'MY_KEY1'
-%0A%09%09%09
 %5D,%0A%09%09%09'camel
@@ -1782,37 +1782,32 @@
  mirrorKey(%0A%09%09%09%7B
-%0A%09%09%09%09
 MY_KEY1: null%0A%09%09
@@ -1795,36 +1795,32 @@
 %09%09%7BMY_KEY1: null
-%0A%09%09%09
 %7D,%0A%09%09%09'lower-cas
@@ -1892,37 +1892,32 @@
  mirrorKey(%0A%09%09%09%5B
-%0A%09%09%09%09
 'MY_KEY1'%0A%09%09%09%5D,%0A
@@ -1901,36 +1901,32 @@
 y(%0A%09%09%09%5B'MY_KEY1'
-%0A%09%09%09
 %5D,%0A%09%09%09'lower-cas
@@ -2049,37 +2049,32 @@
  mirrorKey(%0A%09%09%09%7B
-%0A%09%09%09%09
 MY_KEY1: null%0A%09%09
@@ -2066,28 +2066,24 @@
 Y_KEY1: null
-%0A%09%09%09
 %7D,%0A%09%09%09'dashe
@@ -2155,37 +2155,32 @@
  mirrorKey(%0A%09%09%09%5B
-%0A%09%09%09%09
 'MY_KEY1'%0A%09%09%09%5D,%0A
@@ -2168,28 +2168,24 @@
 %09%09%5B'MY_KEY1'
-%0A%09%09%09
 %5D,%0A%09%09%09'dashe
@@ -2322,21 +2322,16 @@
 ey(%0A%09%09%09%7B
-%0A%09%09%09%09
 MY_KEY1:
@@ -2335,20 +2335,16 @@
 Y1: null
-%0A%09%09%09
 %7D,%0A%09%09%09'l
@@ -2438,13 +2438,8 @@
 %09%09%09%5B
-%0A%09%09%09%09
 'MY_
@@ -2443,20 +2443,16 @@
 MY_KEY1'
-%0A%09%09%09
 %5D,%0A%09%09%09'l

Make tests a bit more readable