var should = require("should");
var loader = require("../");

function loadAndEval() {
	var module = {};
	eval(loader.call.apply(loader, arguments));
	return module.exports;
}

describe("loader", function() {
	
	it("should convert to requires", function() {
		loadAndEval({}, '<h1>Hello World</h1>')().should.be.eql(
			'<h1>Hello World</h1>'
		);
	});

	it("should allow to pass values", function() {
		loadAndEval({}, '<h1>Hello <%= name %></h1>')({name : 'Moon'}).should.be.eql(
			'<h1>Hello Moon</h1>'
		);
	});

	it("should allow to minify html", function() {
		loadAndEval({
		   query: "?minimize=true"
		}, '<h1  >Hello <%= name %></h1>')({name : 'Moon'})
		.should.be.eql(
			'<h1>Hello Moon</h1>'
		);
	});

	it("should allow to minify html and collapse whitespaces", function() {
		loadAndEval({
		   query: "?minimize=true&collapseWhitespace=true"
		}, '<div>\n<h1>Hello <span><%= name %></span></h1>\n</div>')({name : 'Moon'})
		.should.be.eql(
			'<div><h1>Hello <span>Moon</span></h1></div>'
		);
	});

	it("should allow to use bracket notation html", function() {
		loadAndEval({
		   query: "?evaluate=\\{\\[([\\s\\S]+?)\\]\\}&interpolate=\\{\\{([\\s\\S]+?)\\}\\}"
		}, '<h1>Hello {{ name }}</h1>')({name : 'Moon'})
		.should.be.eql(
			'<h1>Hello Moon</h1>'
		);
	});

	it("should allow to use lodash", function() {
		loadAndEval({query: "?lodash=true"}, '<% _.each(items, function(item){ %><%= item %><% }) %>')
		({items: [1, 2, 3, 4, 5]})
		.should.be.eql(
			'12345'
		);
	});
});

@@ -704,32 +704,276 @@
 h1%3E'%0A%09%09);%0A%09%7D);%0A%0A
+%09it(%22should allow to minify html with data attributes%22, function() %7B%0A%09%09loadAndEval(%7B%0A%09%09   query: %22?minimize=true%22%0A%09%09%7D, '%3Ch1 data-attr=%22%3C%25= name %25%3E%22%3EHello%3C/h1%3E')(%7Bname : 'Moon'%7D)%0A%09%09.should.be.eql(%0A%09%09%09'%3Ch1 data-attr=%22Moon%22%3EHello%3C/h1%3E'%0A%09%09);%0A%09%7D);%0A%0A
 %09it(%22should allo

Add test for data attributes