var tm     = require('../lib/templateManager')
  , expect = require('chai').expect;

describe('Template manager', function() {

  it('should render ejs', function(done) {
    var opts = {
      locals: {item: 'test'},
      filename: 'test.ejs',
      source: '<h1><%= item%> <%= engine%></h1>'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('<h1>test .ejs</h1>');

      done()
    })
  })

  it('should render jade', function(done) {
    var opts = {
      locals: {item: 'test'},
      filename: 'test.jade',
      source: 'h1= item\nh1= engine'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('<h1>test</h1><h1>.jade</h1>');

      done()
    })
  })

  it('should render swig', function(done) {
    var opts = {
      locals: {item: 'test'},
      filename: 'test.swig',
      source: '<h1>{{ item }} {{ engine }}</h1>'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('<h1>test .swig</h1>');

      done()
    })
  })

  it('should render handlebars', function(done) {
    var opts = {
      locals: {item: 'test'},
      filename: 'test.handlebars',
      source: '<h1>{{ item }} {{ engine }}</h1>'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('<h1>test .handlebars</h1>');

      done()
    })
  })

  it('should render less', function(done) {
    var opts = {
      locals   : {},
      filename : 'test.less',
      source   : '.class{ width: (1 + 1) }'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('.class {\n  width: 2;\n}\n');

      done()
    })
  })

  it('should render stylus', function(done) {
    var opts = {locals: {}};
    opts.filename = 'test.stylus';
    opts.source = 'body\n  width: 2px\n';
    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('body {\n  width: 2px;\n}\n');
      done();
    })
  })

  it('should render styl', function(done) {
    var opts = {
      locals   : {whitespace: true},
      filename : 'test.styl',
      source   : 'body\n  color: blue'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('body {\n  color: blue;\n}')
      done()
    })
  })

  it('should render sass', function(done) {
    var opts = {
      locals   : {},
      filename : 'test.sass',
      source   : '$gray: #ccc;body {color: $gray}'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('body {\n  color: #ccc; }\n');

      done()
    })
  })

  it('should render css', function(done) {
    var opts = {
      locals   : {},
      filename : 'test.css',
      source   : 'body { color: #ccc; }'
    }

    tm.render(opts, function(err, res) {
      expect(err).to.be.null;
      expect(res).to.equal('body { color: #ccc; }');

      done()
    })
  })
})
@@ -40,16 +40,45 @@
 nager')%0A
+  , path   = require('path')%0A
   , expe
@@ -108,53 +108,570 @@
 pect
-;%0A%0Adescribe('Template manager', function() %7B%0A
+%0A  ,     fs = require('fs')%0A  , tmpDir = path.join(__dirname, '..', '.tmproj')%0A  , mkdirp = require('mkdirp')%0A  , rimraf = require('rimraf')%0A%0Adescribe('Template manager', function() %7B%0A  /////////////////////////////////////////////////////////////////////////////%0A  // Setup%0A  beforeEach(function(done) %7B%0A    // Setup a tmp directory for test files.%0A    mkdirp(tmpDir, done)%0A  %7D)%0A%0A  afterEach(function(done) %7B%0A    // Destroy all test files.%0A    rimraf(tmpDir, done)%0A  %7D)%0A%0A  /////////////////////////////////////////////////////////////////////////////%0A  // Tests
 %0A  i
@@ -2289,32 +2289,693 @@
 ()%0A    %7D)%0A  %7D)%0A%0A
+  it('should render less with @import statement', function(done) %7B%0A    var testMainLessFile = path.join(tmpDir, 'main.less')%0A    var testIncludesFile = path.join(tmpDir, 'includes.less')%0A%0A    // Write out some test LESS files.%0A    fs.writeFileSync(testMainLessFile, '@import %22includes.less%22;')%0A    fs.writeFileSync(testIncludesFile, '.body %7B color: #333%7D')%0A%0A    var opts = %7B%0A      locals   : %7B%7D,%0A      filename : testMainLessFile,%0A      source   : fs.readFileSync(testMainLessFile).toString()%0A    %7D%0A%0A    tm.render(opts, function(err, res) %7B%0A      expect(err).to.be.null;%0A      expect(res).to.equal('.body %7B%5Cn  color: #333333;%5Cn%7D%5Cn');%0A%0A      done()%0A    %7D)%0A  %7D)%0A%0A
   it('should ren
@@ -4229,8 +4229,9 @@
 %0A  %7D)%0A%7D)
+%0A

Add test to cover less import statements