'use strict';

describe('The ninja-list Directive', function () {

  var element, scope, isolatedScope, tile;
  var serverMock = [
    {
      "age": 55,
      "name": "Daniele",
      "_id": "5693fa5af6976c704e00005a",
      "__v": 0
    },
    {
      "age": 10,
      "name": "Mattia",
      "_id": "5693faf8f6976c704e00005e",
      "__v": 0
    },
    {
      "age": 45,
      "name": "Gianni",
      "_id": "56976b6ef6976c704e000065",
      "__v": 0
    }
  ];
  var mockUserResource, $httpBackend;

  
  // injecting main module
  beforeEach(module('handlingNinja'));
  beforeEach(module('templates'));

  beforeEach(inject(function($compile, $rootScope, $httpBackend) {

    $httpBackend.whenGET('http://178.62.216.211:3001/api/ninja')
    .respond(200, serverMock);

    scope = $rootScope.$new();

    element = angular.element('<ninja-list></ninja-list>');

    $compile(element)(scope);
    scope.$apply();
    $httpBackend.flush();
    isolatedScope = element.isolateScope();
  }));

  it('should have 3 ninjas in scope', function () {
    expect(isolatedScope.nl.ninjas.length).toBe(3);
  });

  it('should render 3 ninjas', function(){ 
     var tiles = element[0].getElementsByTagName('ninja-tile');
     expect(tiles.length).toEqual(3);
   });

});

@@ -99,14 +99,8 @@
 cope
-, tile
 ;%0A  
@@ -130,21 +130,21 @@
 %7B%0A      
-%22age%22
+'age'
 : 55,%0A  
@@ -151,33 +151,33 @@
     
-%22
+'
 name
-%22: %22
+': '
 Daniele
-%22
+'
 ,%0A      
 %22_id
@@ -168,32 +168,32 @@
 ele',%0A      
-%22_id%22: %22
+'_id': '
 5693fa5af697
@@ -204,25 +204,25 @@
 4e00005a
-%22
+'
 ,%0A      
 %22__v%22: 0
@@ -205,37 +205,37 @@
 e00005a',%0A      
-%22__v%22
+'__v'
 : 0%0A    %7D,%0A    %7B
@@ -241,21 +241,21 @@
 %7B%0A      
-%22age%22
+'age'
 : 10,%0A  
@@ -262,32 +262,32 @@
     
-%22
+'
 name
-%22: %22
+': '
 Mattia
-%22
+'
 ,%0A      
 %22_id
@@ -282,24 +282,24 @@
 ,%0A      
-%22_id%22: %22
+'_id': '
 5693faf8
@@ -314,25 +314,25 @@
 4e00005e
-%22
+'
 ,%0A      
 %22__v%22: 0
@@ -315,37 +315,37 @@
 e00005e',%0A      
-%22__v%22
+'__v'
 : 0%0A    %7D,%0A    %7B
@@ -355,13 +355,13 @@
     
-%22age%22
+'age'
 : 45
@@ -372,32 +372,32 @@
     
-%22
+'
 name
-%22: %22
+': '
 Gianni
-%22
+'
 ,%0A      
 %22_id
@@ -396,16 +396,16 @@
     
-%22_id%22: %22
+'_id': '
 5697
@@ -428,17 +428,17 @@
 0065
-%22
+'
 ,%0A      
 %22__v
@@ -437,13 +437,13 @@
     
-%22__v%22
+'__v'
 : 0%0A
@@ -457,49 +457,8 @@
  %5D;%0A
-  var mockUserResource, $httpBackend;%0A%0A  
 %0A  /
@@ -720,17 +720,16 @@
 rMock);%0A
-%0A
     scop
@@ -751,17 +751,16 @@
 $new();%0A
-%0A
     elem
@@ -811,17 +811,16 @@
 ist%3E');%0A
-%0A
     $com
@@ -1096,19 +1096,17 @@
 n()%7B
- %0A 
+%0A
     var 
 tile
@@ -1101,21 +1101,23 @@
     var 
-tiles
+htmlTag
  = eleme
@@ -1158,17 +1158,16 @@
 tile');%0A
- 
     expe
@@ -1173,13 +1173,15 @@
 ect(
-tiles
+htmlTag
 .len
@@ -1199,18 +1199,16 @@
 l(3);%0A  
- 
 %7D);%0A
-%0A
 %7D);%0A

fix ninja-list test