import 'glazier/services/identity' as IdentityService;
import createServiceForTesting from 'helpers/service_test_helpers';
import mockAjax from 'helpers/ajax_test_helpers';

module("Glazier IdentityService Unit", {
  setup: function() {
    this.userController = Ember.Controller.create();
    this.service = createServiceForTesting(IdentityService.extend({
      userController: this.userController
    }), 'card-id');

    this.service.initialize();
    this.service.port.send = function () {
      // stub
    };
  },
  teardown: function() {
  }
});

test("sends 'currentUserChanged' when userController content changes", function () {
  var user = {};

  this.service.port.send = function(event, data) {
    equal(event, 'currentUserChanged');
    equal(data, user);
    start();
  };

  stop();
  Ember.run(this, function () {
    this.userController.set('content', user);
  });
});

test("request 'currentUser' should resolve with the userController content", function () {
  var user = {};
  Ember.run(this, function () {
    this.userController.set('content', user);
  });

  stop();
  this.service.simulateRequest('currentUser').then(function (userJson) {
    equal(userJson, user);
    start();
  });
});

@@ -167,16 +167,70 @@
 pers';%0A%0A
+import 'glazier/controllers/user' as UserController;%0A%0A
 module(%22
@@ -310,22 +310,20 @@
 oller = 
-Emb
+Us
 er
-.
 Controll
@@ -750,24 +750,37 @@
 nt, data) %7B%0A
+    start();%0A
     equal(ev
@@ -830,29 +830,16 @@
  user);%0A
-    start();%0A
   %7D;%0A%0A  
@@ -1207,24 +1207,37 @@
 userJson) %7B%0A
+    start();%0A
     equal(us
@@ -1251,29 +1251,16 @@
  user);%0A
-    start();%0A
   %7D);%0A%7D)

fix failing identity test