'use strict';

const fs = require('fs');
const path = require('path');
const VersionChecker = require('ember-cli-version-checker');

module.exports = function (blueprint) {
  blueprint.supportsAddon = function () {
    return false;
  };

  blueprint.filesPath = function () {
    let type;

    let dependencies = this.project.dependencies();
    if ('ember-qunit' in dependencies) {
      type = 'qunit-rfc-232';
    } else if ('ember-cli-qunit' in dependencies) {
      let checker = new VersionChecker(this.project);
      if (
        fs.existsSync(this.path + '/qunit-rfc-232-files') &&
        checker.for('ember-cli-qunit', 'npm').gte('4.2.0')
      ) {
        type = 'qunit-rfc-232';
      } else {
        type = 'qunit';
      }
    } else if ('ember-mocha' in dependencies) {
      let checker = new VersionChecker(this.project);
      if (
        fs.existsSync(this.path + '/mocha-rfc-232-files') &&
        checker.for('ember-mocha', 'npm').gte('0.14.0')
      ) {
        type = 'mocha-rfc-232';
      } else {
        type = 'mocha-0.12';
      }
    } else if ('ember-cli-mocha' in dependencies) {
      let checker = new VersionChecker(this.project);
      if (
        fs.existsSync(this.path + '/mocha-0.12-files') &&
        checker.for('ember-cli-mocha', 'npm').gte('0.12.0')
      ) {
        type = 'mocha-0.12';
      } else {
        type = 'mocha';
      }
    } else {
      this.ui.writeLine("Couldn't determine test style - using QUnit");
      type = 'qunit';
    }

    return path.join(this.path, type + '-files');
  };

  return blueprint;
};

@@ -283,16 +283,145 @@
 et type;
+%0A    const qunitRfcVersion = 'qunit-rfc-232';%0A    const mochaRfcVersion = 'mocha-rfc-232';%0A    const mochaVersion = 'mocha-0.12';
 %0A%0A    le
@@ -516,39 +516,39 @@
      type = 
-'
 qunit
--rfc-232'
+RfcVersion
 ;%0A    %7D else
@@ -668,32 +668,35 @@
   fs.existsSync(
+%60$%7B
 this.path + '/qu
@@ -692,33 +692,35 @@
 path
- + '/qunit-rfc-232
+%7D/$%7BqunitRfcVersion%7D
 -files
-'
+%60
 ) &&
@@ -804,31 +804,31 @@
  type = 
-'
 qunit
--rfc-232'
+RfcVersion
 ;%0A      
@@ -995,32 +995,35 @@
   fs.existsSync(
+%60$%7B
 this.path + '/mo
@@ -1019,33 +1019,35 @@
 path
- + '/mocha-rfc-232
+%7D/$%7BmochaRfcVersion%7D
 -files
-'
+%60
 ) &&
@@ -1128,31 +1128,31 @@
  type = 
-'
 mocha
--rfc-232'
+RfcVersion
 ;%0A      
@@ -1171,36 +1171,36 @@
      type = 
-'
 mocha
--0.12'
+Version
 ;%0A      %7D%0A  
@@ -1336,16 +1336,19 @@
 stsSync(
+%60$%7B
 this.pat
@@ -1352,30 +1352,32 @@
 path
- + '/mocha-0.12
+%7D/$%7BmochaVersion%7D
 -files
-'
+%60
 ) &&
@@ -1462,28 +1462,28 @@
  type = 
-'
 mocha
--0.12'
+Version
 ;%0A      

add constants to test-framework-detector