/*global QUnit*/
(function() {
'use strict';

/*global splitSelectors*/
QUnit.test('splitSelectors', function(assert) {
	assert.deepEqual(splitSelectors('foo'), ['foo'], 'Simple selector doesn’t get split');
	assert.deepEqual(splitSelectors('foo,foo\t\n ,\t\n foo'), ['foo', 'foo', 'foo'], 'Simple selectors do get split');
});

/*global getSpecificity*/
QUnit.test('getSpecificity', function(assert) {

	var data = [
		['', 0, 'empty'],
		['div', 1, 'tag'],
		['.class', 256, 'class'],
		['#id', 256 * 256, 'ID'],
		['div.class#id', 256 * 256 + 256 + 1, 'tag, class and ID'],
		['::after', 1, 'pseudo element'],
		[':hover', 256, 'pseudo class'],
		['[foo="bar"]', 256, 'attribute'],
		['.\\:container\\(max-width\\:1px\\)', 256, 'escaped container query'],
	];

	data.forEach(function(item) {
		assert.equal(
			getSpecificity(item[0]), item[1], item[2][0].toUpperCase() + item[2].substr(1) + ' ("' + item[0] + '")' + ': ' + item[1]);
	});

	var allSelectors = data.reduce(function(all, item) { return all + ' ' + item[0]; }, '').trim();
	var allSpecifity = data.reduce(function(all, item) { return all + item[1]; }, 0);
	assert.equal(getSpecificity(allSelectors), allSpecifity, 'All combined ("' + allSelectors.trim() + '")' + ': ' + allSpecifity);

	data.reverse();
	allSelectors = data.reduce(function(all, item) { return all + ' ' + item[0]; }, '').trim();
	allSpecifity = data.reduce(function(all, item) { return all + item[1]; }, 0);
	assert.equal(getSpecificity(allSelectors), allSpecifity, 'All combined reverse ("' + allSelectors.trim() + '")' + ': ' + allSpecifity);

});

})();

@@ -322,16 +322,526 @@
 );%0A%7D);%0A%0A
+/*global sortRulesBySpecificity*/%0AQUnit.test('sortRulesBySpecificity', function(assert) %7B%0A%09var unsorted = %5B%0A%09%09%7Bselector: 'tag'%7D,%0A%09%09%7Bselector: '.class'%7D,%0A%09%09%7Bselector: '#id'%7D,%0A%09%09%7Bselector: 'tag tag'%7D,%0A%09%09%7Bselector: '.class.class'%7D,%0A%09%09%7Bselector: '#id#id'%7D,%0A%09%5D;%0A%09var sorted = %5B%0A%09%09%7Bselector: '#id#id'%7D,%0A%09%09%7Bselector: '#id'%7D,%0A%09%09%7Bselector: '.class.class'%7D,%0A%09%09%7Bselector: '.class'%7D,%0A%09%09%7Bselector: 'tag tag'%7D,%0A%09%09%7Bselector: 'tag'%7D,%0A%09%5D;%0A%09assert.deepEqual(sortRulesBySpecificity(unsorted), sorted, 'Correct sort order');%0A%7D);%0A%0A
 /*global

Test sortRulesBySpecificity