describe('Module: angularjs-input-tags -', () => {
  let $componentController;

  beforeEach(angular.mock.module('angularjs-input-tags'));
  beforeEach(angular.mock.inject(_$componentController_ => {
    $componentController = _$componentController_;
  }));

  describe('Component: inputTags -', () => {
    let ctrl;

    beforeEach(() => {
      ctrl = $componentController('inputTags', {
        $element: angular.element('<div></div>')
      }, {
        onTagAdding: jasmine.createSpy('onTagAdding'),
        onTagRemoving: jasmine.createSpy('onTagRemoving')
      });
    });
    describe('Event: onTagAdding', () => {
      it('should be emit', () => {
        ctrl.$onInit();
        ctrl.addTag({code: 1, text: '1'});
        expect(ctrl.onTagAdding).toHaveBeenCalled();
      });

      it('should be emit with formatted tag value', () => {
        ctrl.$onInit();
        ctrl.addTag({code: 1, text: '1'});
        expect(ctrl.onTagAdding).toHaveBeenCalledWith({tag: {code: 1, text: '1'}});
      });
    });

    it('should add tag on list', () => {
      ctrl.$onInit();
      ctrl.addTag({code: 1, text: '1'});
      expect(ctrl.tags).toContain({code: 1, text: '1'});
    });

    it('should update tag list', () => {
      ctrl.$onInit();
      ctrl.addTag({code: 1, text: '1'});
      ctrl.addTag({code: 1, text: '1'});
      ctrl.addTag({code: 1, text: '1'});
      expect(ctrl.tags.length).toBe(1);
    });

    it('should display autocomplete on focus', () => {
      ctrl.$onInit();
      ctrl.triggerFocus();
      expect(ctrl.autocompleteVisible).toBe(true);
    });

    it('should hide autocomplete on blur', () => {
      ctrl.$onInit();
      ctrl.triggerBlur();
      expect(ctrl.autocompleteVisible).toBe(false);
    });

    it('should emit `onTagRemoving` event', () => {
      ctrl.$onInit();
      ctrl.tags = ['Demo'];
      ctrl.removeTag({code: 1, text: '1'});
      expect(ctrl.onTagRemoving).toHaveBeenCalled();
      expect(ctrl.onTagRemoving).toHaveBeenCalledWith({tag: {code: 1, text: '1'}});
    });

    it('should remove matching element by code', () => {
      ctrl.$onInit();
      ctrl.tags.length = 0;
      ctrl.addTag({code: 1, text: '1'});
      ctrl.removeTag({code: 1});
      expect(ctrl.tags.length).toBe(0);
    });

    it('should reset the tag list', () => {
      ctrl.$onInit();
      expect(ctrl.path.length).toBe(0);
    });

    it('should go to the selected element in the tree', () => {
      ctrl.$onInit();
      const pathLength = ctrl.path.length;
      ctrl.next('subLevel');
      expect(ctrl.path.length).toBe(pathLength + 1);
    });

    it('should back to the previous element in the tree when on the root', () => {
      ctrl.$onInit();
      ctrl.path = [];
      ctrl.previous();
      expect(ctrl.path.length).toBe(0);
    });

    it('should back to the previous element in the tree when in 2 sublevels', () => {
      ctrl.$onInit();
      ctrl.next('subLevel');
      ctrl.next('subSubLevel');
      ctrl.previous();
      expect(ctrl.path.length).toBe(1);
    });
  });
});

@@ -1006,32 +1006,416 @@
    %7D);%0A    %7D);%0A%0A
+    describe('Event: onTagRemoving', () =%3E %7B%0A      it('should be emit', () =%3E %7B%0A        ctrl.$onInit();%0A        ctrl.tags = %5B'Demo'%5D;%0A        ctrl.removeTag(%7Bcode: 1, text: '1'%7D);%0A        expect(ctrl.onTagRemoving).toHaveBeenCalled();%0A        expect(ctrl.onTagRemoving).toHaveBeenCalledWith(%7Btag: %7Bcode: 1, text: '1'%7D%7D);%0A      %7D);%0A    %7D);%0A%0A    describe('Action: add a tag', () =%3E %7B%0A  
     it('should a
@@ -1431,32 +1431,34 @@
  list', () =%3E %7B%0A
+  
       ctrl.$onIn
@@ -1461,32 +1461,34 @@
 onInit();%0A      
+ 
+ 
 ctrl.addTag(%7Bcod
@@ -1498,32 +1498,34 @@
 1, text: '1'%7D);%0A
+  
       expect(ctr
@@ -1561,32 +1561,34 @@
 ext: '1'%7D);%0A    
+  
 %7D);%0A%0A    it('sho
@@ -1572,32 +1572,34 @@
 %0A      %7D);%0A%0A    
+ 
+ 
 it('should updat
@@ -1617,32 +1617,34 @@
 , () =%3E %7B%0A      
+  
 ctrl.$onInit();%0A
@@ -1635,32 +1635,34 @@
 ctrl.$onInit();%0A
+  
       ctrl.addTa
@@ -1684,32 +1684,34 @@
 t: '1'%7D);%0A      
+  
 ctrl.addTag(%7Bcod
@@ -1721,32 +1721,34 @@
 1, text: '1'%7D);%0A
+  
       ctrl.addTa
@@ -1770,32 +1770,34 @@
 t: '1'%7D);%0A      
+  
 expect(ctrl.tags
@@ -1806,32 +1806,42 @@
 ength).toBe(1);%0A
+      %7D);%0A
     %7D);%0A%0A    it(
@@ -2161,300 +2161,8 @@
 );%0A%0A
-    it('should emit %60onTagRemoving%60 event', () =%3E %7B%0A      ctrl.$onInit();%0A      ctrl.tags = %5B'Demo'%5D;%0A      ctrl.removeTag(%7Bcode: 1, text: '1'%7D);%0A      expect(ctrl.onTagRemoving).toHaveBeenCalled();%0A      expect(ctrl.onTagRemoving).toHaveBeenCalledWith(%7Btag: %7Bcode: 1, text: '1'%7D%7D);%0A    %7D);%0A%0A
     

reorganize tests order