/**
 * @license Copyright (c) 2012, Viet Trinh All Rights Reserved.
 * Available via MIT license.
 */

/**
 * Test for string.
 */
define([ 'qunit', 'framework/core/utils/string' ], 
function(q, StringUtils)
{
	q.module('Core - utils/string');

	q.test('Can capitalize/un-capitalize first letter.', function() 
	{
		q.expect(4);

		q.equal(StringUtils.capitalizeFirstLetter('letter'), 'Letter', 'Captializing first letter of a word.');
		q.equal(StringUtils.capitalizeFirstLetter('a'), 'A', 'Captializing a letter.');

		q.equal(StringUtils.unCapitalizeFirstLetter('Letter'), 'letter', 'Un-captializing first letter of a word.');
		q.equal(StringUtils.unCapitalizeFirstLetter('A'), 'a', 'Un-captializing a letter.');
	});

	q.test('Add ellipsis to text.', function() 
	{
		q.expect(3);

		q.equal(StringUtils.ellipsis('Is this too long or is it really too long'), 'Is this too long or  \u2026', 'Adding ellipsis because it\'s too long');
		q.equal(StringUtils.ellipsis('1234567890123456789012'), '1234567890123456789012', 'No ellipsis, just short enough.');
		q.equal(StringUtils.ellipsis('1234567890123456789012', 13), '1234567890 \u2026', 'Adding ellipsis with a custom length.');
	});

	q.test('Can pad strings with characters.', function() 
	{
		q.expect(2);

		q.equal(StringUtils.padLeft('L', 5, 'o'), 'ooooL', 'Can pad left.');
		q.equal(StringUtils.padRight('L', 3, 'o'), 'Loo', 'Can pad right.');
	});

	q.test('Can escape html characters.', function() 
	{
		q.expect(1);

		q.equal(StringUtils.escapeHtml('<&>'), '&lt;&amp;&gt;', 'Can properly escape the &, <, and > chararcters.');
	});

	q.test('Can format strings.', function() 
	{
		q.expect(4);

		q.equal(StringUtils.format('Nothing formatted', 'no replace'), 'Nothing formatted', 'No format parameters.');
		q.equal(StringUtils.format('Something {0} formatted', 'great is'), 'Something great is formatted', 'One format parameters.');
		q.equal(StringUtils.format('Something {0} and {1} formatted', 'great', 'greater is'), 'Something great and greater is formatted', 'Two format parameters.');
		q.equal(StringUtils.format('{0}{1}', '{1}', '{0}'), '{1}{0}', 'Special case from stackoverflow.');
	});

	q.test('Can camel case strings.', function()
	{
		q.expect(1);

		q.equal(StringUtils.toCamel('One_two_threeFour'), 'oneTwoThreeFour', 'Can convert to camel case.');
	});

	q.test('Can pascal case strings.', function()
	{
		q.expect(1);

		q.equal(StringUtils.toPascal('one_two-threeFour'), 'OneTwoThreeFour', 'Can convert to pascal case.');
	});

});