/*global describe, beforeEach, it*/
'use strict';

var path = require('path');
var helpers = require('yeoman-generator').test;


describe('protractor generator', function() {
  var app;

  beforeEach(function(done) {
    helpers.testDirectory(path.join(__dirname, 'temp'), function(err) {
      if (err) {
        return done(err);
      }

      app = helpers.createGenerator('protractor:app', [
        '../../app'
      ]);
      done();
    });
  });

  /**
   * Create a protractor project.
   * @param {string} configFileName Protractor config name.
   */
  var createProject = function(configFileName) {
    helpers.mockPrompt(app, {
      'configName': configFileName
    });
    app.options['skip-install'] = true;
    app.run({}, function() {
    });
  };

  it('should create config file and package.json', function(done) {
    var configFileName = 'theConfigFileName.js';

    helpers.mockPrompt(app, {
      'configName': configFileName
    });
    app.options['skip-install'] = true;
    app.run({}, function() {
      helpers.assertFiles([
        configFileName,
        'package.json'
      ]);
      done();
    });
  });

  describe('Unit test creation', function() {
    var generator;

    /**
     * Call the sub-generator to create a unit test.
     * @param {string} configName Protractor configuration file name.
     */
    var createUnitTest = function(configName) {
      createProject(configName);
      generator = helpers.createGenerator('protractor:unit', [
        '../../unit'
      ], 'my-test');
    };

    /**
     * Make sure the uni test was added to the config file.
     * @param {string} configName Protractor configuration file name.
     * @param {function} done Done callback.
     */
    var ensureUnitTestWasAddedToConfig = function(configName, done) {
      generator.run({}, function() {
        // Ensure the unit test file was created.
        helpers.assertFiles([
          'spec/my-test-spec.js',
          configName
        ]);

        // And ensure the config file contains the unit test.
        helpers.assertFiles([
          [configName, /'spec\/my-test-spec.js'/]
        ]);

        done();
      });
    };

    it('should create a protractor unit test', function(done) {
      var configName = 'protractor-config.js';

      createUnitTest(configName);

      helpers.mockPrompt(generator, {
        'testType': 'protractor'
      });

      ensureUnitTestWasAddedToConfig(configName, done);
    });

    it('should ask for protractor config file name', function(done) {
      var configName = 'theConf.js';

      createUnitTest(configName);

      helpers.mockPrompt(generator, {
        'configFileName': configName
      });

      ensureUnitTestWasAddedToConfig(configName, done);
    });
  });
});

@@ -760,16 +760,62 @@
 ;%0A  %7D;%0A%0A
+  describe('Project creation', function() %7B%0A  
   it('sh
@@ -874,24 +874,26 @@
 done) %7B%0A    
+  
 var configFi
@@ -926,24 +926,26 @@
 e.js';%0A%0A    
+ 
+ 
 helpers.mock
@@ -950,32 +950,34 @@
 ckPrompt(app, %7B%0A
+  
       'configNam
@@ -987,32 +987,34 @@
  configFileName%0A
+  
     %7D);%0A    app.
@@ -1001,32 +1001,34 @@
 e%0A      %7D);%0A    
+  
 app.options%5B'ski
@@ -1043,32 +1043,34 @@
 l'%5D = true;%0A    
+  
 app.run(%7B%7D, func
@@ -1080,24 +1080,26 @@
 n() %7B%0A      
+ 
+ 
 helpers.asse
@@ -1112,24 +1112,26 @@
 s(%5B%0A        
+  
 configFileNa
@@ -1134,16 +1134,18 @@
 leName,%0A
+  
         
@@ -1157,36 +1157,40 @@
 age.json'%0A      
+  
 %5D);%0A
+  
       done();%0A  
@@ -1179,32 +1179,42 @@
         done();%0A
+      %7D);%0A
     %7D);%0A  %7D);%0A%0A 

Add describe for 'Project creation'