import {
  Controller
} from 'ember-runtime';
import controllerFor from '../../system/controller_for';
import generateController from '../../system/generate_controller';
import { EMBER_NO_DOUBLE_EXTEND } from 'ember/features';
import { moduleFor, ApplicationTestCase } from 'internal-test-helpers';

moduleFor('Ember.controllerFor', class extends ApplicationTestCase {
  ['@test controllerFor should lookup for registered controllers'](assert) {
    this.add('controller:app', Controller.extend());

    return this.visit('/').then(() => {
      let appInstance = this.applicationInstance;
      let appController = appInstance.lookup('controller:app');
      let controller = controllerFor(appInstance, 'app');
      assert.equal(appController, controller, 'should find app controller');
    });
  }
});

moduleFor('Ember.generateController', class extends ApplicationTestCase {
  ['@test generateController should return Ember.Controller'](assert) {
    return this.visit('/').then(() => {
      let controller = generateController(this.applicationInstance, 'home');
      assert.ok(controller instanceof Controller, 'should return controller');
    });
  }

  ['@test generateController should return App.Controller if provided'](assert) {
    let MainController = Controller.extend();
    this.add('controller:basic', MainController);

    return this.visit('/').then(() => {
      let controller = generateController(this.applicationInstance, 'home');
      assert.ok(controller instanceof MainController, 'should return controller');
    });
  }

  ['@test generateController should return controller:basic if provided'](assert) {
    let controller;
    let BasicController = Controller.extend();
    this.add('controller:basic', BasicController);

    return this.visit('/').then(() => {
      controller = generateController(this.applicationInstance, 'home');

      if (EMBER_NO_DOUBLE_EXTEND) {
        assert.ok(controller instanceof BasicController, 'should return base class of controller');
      } else {
        let doubleExtendedFactory;
        ignoreDeprecation(() => {
          doubleExtendedFactory = this.applicationInstance._lookupFactory('controller:basic');
        });
        assert.ok(controller instanceof doubleExtendedFactory, 'should return double-extended controller');
      }
    });
  }
});

@@ -1201,13 +1201,9 @@
 urn 
-App.C
+c
 ontr
@@ -1207,26 +1207,32 @@
 ntroller
- if provid
+:basic if resolv
 ed'%5D(ass
@@ -1246,20 +1246,21 @@
     let 
-Main
+Basic
 Controll
@@ -1318,20 +1318,21 @@
 basic', 
-Main
+Basic
 Controll
@@ -1496,12 +1496,13 @@
 eof 
-Main
+Basic
 Cont
@@ -1618,14 +1618,16 @@
  if 
-provid
+register
 ed'%5D
@@ -1641,28 +1641,8 @@
 ) %7B%0A
-    let controller;%0A
     
@@ -1686,34 +1686,51 @@
 nd();%0A    this.a
-dd
+pplication.register
 ('controller:bas
@@ -1799,16 +1799,20 @@
 %7B%0A      
+let 
 controll

Improve test names