/* global require, describe, beforeEach, afterEach, it */
var broccoli = require('broccoli');
var chai = require('chai');
var linter = require('..');

var assert = chai.assert;

var builder, errors;

function buildAndLint(sourcePath) {
  linter.included({
    isTestingStyleLintAddon: true,
    options: {
      styleLint:{
        onError: function(results) {
          console.log(results)
          errors.push(results);
        },
        generateTests:true
      }
    },
    trees: {
      styles: sourcePath, // Directory to lint
    },
  });

  var node = linter.lintTree('app', {
    tree: sourcePath
  });

  builder = new broccoli.Builder(node);

  return builder.build();
}

describe('ember-cli-style-lint', function() {
  console.log('making tests')
  beforeEach(function() {
    errors = [];
  });

  afterEach(function() {
    if (builder) {
      builder.cleanup();
    }
  });

  it('The linter should run', function() {
    console.log('running test');
    return buildAndLint('tests/dummy').then(function() {
      var firstError = errors[0];
      var messageIdStrings;

      assert.ok(!!firstError,
        'The linting should occur');

      assert.equal(firstError.source, 'app/styles/app.scss',
        'The app.scss file should be linted');

      assert.ok(firstError.warnings.length == 2,
        'Found correct amount of errors');
    });
  });
});

@@ -358,39 +358,8 @@
 ) %7B%0A
-          console.log(results)%0A
     
@@ -386,16 +386,16 @@
 sults);%0A
+
         
@@ -699,38 +699,8 @@
 ) %7B%0A
-  console.log('making tests')%0A
   be
@@ -874,41 +874,8 @@
 ) %7B%0A
-    console.log('running test');%0A
     
@@ -964,36 +964,8 @@
 %5B0%5D;
-%0A      var messageIdStrings;
 %0A%0A  
@@ -1135,24 +1135,24 @@
  linted');%0A%0A
-
       assert
@@ -1184,16 +1184,17 @@
 ength ==
+=
  2,%0A    

clean up test code