
/**
 * Test dependencies.
 */

var mouth = require('..');
var assert = require('assert');

describe("compiler", function() {
	
	it('should return a compiled function', function() {
		var result = mouth('${ beep }').text;
		assert.equal(result({
			beep: 'boop'
		}), 'boop');
	});

	it('should return a compiled function from an advanced expresion', function() {
		var result = mouth('${ beep + boop }').text;
		assert.equal(result({
			beep: 'boop',
			boop: 'hello'
		}), 'boophello');
	});

	it('should return the expression properties', function() {
		var props = mouth('${beep} and ${boop}').props;
		assert.deepEqual(props, ['beep', 'boop']);
	})

	it('should compile complex expressions', function() {
		var result = mouth('${beep + " " + cb()}').text;
		assert.equal(result({
			beep: 'hello',
			cb: function() {
				return 'world!';
			}
		}), 'hello world!');
	});


});


// 
// /\$([^{}]*)\{([^{}]*)\}/g

// describe("mixins", function() {

// 	var tmpl;
// 	beforeEach(function() {
// 		tmpl = mouth({
// 			link: 'home'
// 		});
// 	});

// 	it("should add middlware", function() {
// 		tmpl.use('path', function(str) {
// 			return '/path/' + this[str.trim()];
// 		});
// 		var result = tmpl('$path{link}');
// 		assert.equal(result, '/path/home');
// 	});

// });

describe("filters", function() {
	
});



@@ -81,24 +81,25 @@
 'assert');%0A%0A
+%0A
 describe(%22co
@@ -99,73 +99,14 @@
 ibe(
-%22compiler%22, function() %7B%0A%09%0A%09it('should return a compiled function
+'basic
 ', f
@@ -113,38 +113,44 @@
 unction() %7B%0A
-%09
+%0A
 %09var 
-result
+interpolate
  =
+ 
  mouth('$%7B b
@@ -151,288 +151,99 @@
 ('$%7B
- beep %7D').text;%0A%09%09assert.equal(result(%7B%0A%09%09%09beep: 'boop'%0A%09%09%7D), 'boop');%0A%09%7D);%0A%0A%09it('should return a compiled function from an advanced expresion', function() %7B%0A%09%09var result = mouth('$%7B beep + boop %7D').text;%0A%09%09assert.equal(result(%7B%0A%09%09%09beep: 'boop',%0A%09%09%09boop: 'hello'%0A%09%09%7D), 'boophello'
+name%7D');%0A%0A%09it('should return a function', function() %7B%0A%09%09assert.equal(typeof interpolate%5B0%5D
 );%0A%09
@@ -243,24 +243,25 @@
 %5B0%5D);%0A%09%7D);%0A%0A
+%0A
 %09it('should 
@@ -271,147 +271,100 @@
 urn 
-the expression properties', function() %7B%0A%09%09var props = mouth('$%7Bbeep%7D and $%7Bboop%7D').props;%0A%09%09assert.deepEqual(props, %5B'beep', 'boop
+a list of variable to interpolate', function() %7B%0A%09%09assert.deepEqual(mouth%5B1%5D, %5B'name
 '%5D);%0A%09%7D)
 %0A%0A%09i
@@ -359,16 +359,17 @@
 '%5D);%0A%09%7D)
+;
 %0A%0A%09it('s
@@ -378,662 +378,119 @@
 uld 
-compile complex expressions', function() %7B%0A%09%09var result = mouth('$%7Bbeep + %22 %22 + cb()%7D').text;%0A%09%09assert.equal(result(%7B%0A%09%09%09beep: 'hello',%0A%09%09%09cb: function() %7B%0A%09%09%09%09return 'world!';%0A%09%09%09%7D%0A%09%09%7D), 'hello world!');%0A%09%7D);%0A%0A%0A%7D);%0A%0A%0A// %0A// /%5C$(%5B%5E%7B%7D%5D*)%5C%7B(%5B%5E%7B%7D%5D*)%5C%7D/g%0A%0A// describe(%22mixins%22, function() %7B%0A%0A// %09var tmpl;%0A// %09beforeEach(function() %7B%0A// %09%09tmpl = mouth(%7B%0A// %09%09%09link: 'home'%0A// %09%09%7D);%0A// %09%7D);%0A%0A// %09it(%22should add middlware%22, function() %7B%0A// %09%09tmpl.use('path', function(str) %7B%0A// %09%09%09return '/path/' + this%5Bstr.trim()%5D;%0A// %09%09%7D);%0A// %09%09var result = tmpl('$path%7Blink%7D');%0A// %09%09assert.equal(result, '/path/home');%0A// 
+interpolate variable', function() %7B%0A%09%09assert.equal(interpolate%5B0%5D(%7B%0A%09%09%09name: 'olivier'%0A%09%09%7D), 'olivier';)%0A
 %09%7D);%0A%0A
-// 
 %7D);%0A
-%0Adescribe(%22filters%22, function() %7B%0A%09%0A%7D);%0A%0A%0A

refactor basic test