|
1 | 1 | describe('Module: angularjs-input-tags -', () => { |
2 | | - let $componentController; |
| 2 | + let $componentController |
3 | 3 |
|
4 | | - beforeEach(angular.mock.module('angularjs-input-tags')); |
| 4 | + beforeEach(angular.mock.module('angularjs-input-tags')) |
5 | 5 | beforeEach(angular.mock.inject(_$componentController_ => { |
6 | | - $componentController = _$componentController_; |
7 | | - })); |
| 6 | + $componentController = _$componentController_ |
| 7 | + })) |
8 | 8 |
|
9 | 9 | describe('Component: inputTags -', () => { |
10 | | - let ctrl; |
| 10 | + let ctrl |
11 | 11 |
|
12 | 12 | beforeEach(() => { |
13 | 13 | ctrl = $componentController('inputTags', { |
14 | 14 | $element: angular.element('<div></div>') |
15 | 15 | }, { |
16 | 16 | onTagAdding: jasmine.createSpy('onTagAdding'), |
17 | 17 | onTagRemoving: jasmine.createSpy('onTagRemoving') |
18 | | - }); |
19 | | - }); |
| 18 | + }) |
| 19 | + }) |
20 | 20 | describe('Event: onTagAdding', () => { |
21 | 21 | it('should be emit', () => { |
22 | | - ctrl.$onInit(); |
23 | | - ctrl.addTag({code: 1, text: '1'}); |
24 | | - expect(ctrl.onTagAdding).toHaveBeenCalled(); |
25 | | - }); |
| 22 | + ctrl.$onInit() |
| 23 | + ctrl.addTag({code: 1, text: '1'}) |
| 24 | + expect(ctrl.onTagAdding).toHaveBeenCalled() |
| 25 | + }) |
26 | 26 |
|
27 | 27 | it('should be emit with formatted tag value', () => { |
28 | | - ctrl.$onInit(); |
29 | | - ctrl.addTag({code: 1, text: '1'}); |
30 | | - expect(ctrl.onTagAdding).toHaveBeenCalledWith({tag: {code: 1, text: '1'}}); |
31 | | - }); |
32 | | - }); |
| 28 | + ctrl.$onInit() |
| 29 | + ctrl.addTag({code: 1, text: '1'}) |
| 30 | + expect(ctrl.onTagAdding).toHaveBeenCalledWith({tag: {code: 1, text: '1'}}) |
| 31 | + }) |
| 32 | + }) |
33 | 33 |
|
34 | 34 | describe('Event: onTagRemoving', () => { |
35 | 35 | it('should be emit', () => { |
36 | | - ctrl.$onInit(); |
37 | | - ctrl.tags = ['Demo']; |
38 | | - ctrl.removeTag({code: 1, text: '1'}); |
39 | | - expect(ctrl.onTagRemoving).toHaveBeenCalled(); |
40 | | - expect(ctrl.onTagRemoving).toHaveBeenCalledWith({tag: {code: 1, text: '1'}}); |
41 | | - }); |
42 | | - }); |
| 36 | + ctrl.$onInit() |
| 37 | + ctrl.tags = ['Demo'] |
| 38 | + ctrl.removeTag({code: 1, text: '1'}) |
| 39 | + expect(ctrl.onTagRemoving).toHaveBeenCalled() |
| 40 | + expect(ctrl.onTagRemoving).toHaveBeenCalledWith({tag: {code: 1, text: '1'}}) |
| 41 | + }) |
| 42 | + }) |
43 | 43 |
|
44 | 44 | describe('Action: add a tag', () => { |
45 | 45 | it('should add tag on list', () => { |
46 | | - ctrl.$onInit(); |
47 | | - ctrl.addTag({code: 1, text: '1'}); |
48 | | - expect(ctrl.tags).toContain({code: 1, text: '1'}); |
49 | | - }); |
| 46 | + ctrl.$onInit() |
| 47 | + ctrl.addTag({code: 1, text: '1'}) |
| 48 | + expect(ctrl.tags).toContain({code: 1, text: '1'}) |
| 49 | + }) |
50 | 50 |
|
51 | 51 | it('should update tag list', () => { |
52 | | - ctrl.$onInit(); |
53 | | - ctrl.addTag({code: 1, text: '1'}); |
54 | | - ctrl.addTag({code: 1, text: '1'}); |
55 | | - ctrl.addTag({code: 1, text: '1'}); |
56 | | - expect(ctrl.tags.length).toBe(1); |
57 | | - }); |
58 | | - }); |
| 52 | + ctrl.$onInit() |
| 53 | + ctrl.addTag({code: 1, text: '1'}) |
| 54 | + ctrl.addTag({code: 1, text: '1'}) |
| 55 | + ctrl.addTag({code: 1, text: '1'}) |
| 56 | + expect(ctrl.tags.length).toBe(1) |
| 57 | + }) |
| 58 | + }) |
59 | 59 |
|
60 | 60 | it('should display autocomplete on focus', () => { |
61 | | - ctrl.$onInit(); |
62 | | - ctrl.triggerFocus(); |
63 | | - expect(ctrl.autocompleteVisible).toBe(true); |
64 | | - }); |
| 61 | + ctrl.$onInit() |
| 62 | + ctrl.triggerFocus() |
| 63 | + expect(ctrl.autocompleteVisible).toBe(true) |
| 64 | + }) |
65 | 65 |
|
66 | 66 | it('should hide autocomplete on blur', () => { |
67 | | - ctrl.$onInit(); |
68 | | - ctrl.triggerBlur(); |
69 | | - expect(ctrl.autocompleteVisible).toBe(false); |
70 | | - }); |
| 67 | + ctrl.$onInit() |
| 68 | + ctrl.triggerBlur() |
| 69 | + expect(ctrl.autocompleteVisible).toBe(false) |
| 70 | + }) |
71 | 71 |
|
72 | 72 | it('should remove matching element by code', () => { |
73 | | - ctrl.$onInit(); |
74 | | - ctrl.tags.length = 0; |
75 | | - ctrl.addTag({code: 1, text: '1'}); |
76 | | - ctrl.removeTag({code: 1}); |
77 | | - expect(ctrl.tags.length).toBe(0); |
78 | | - }); |
| 73 | + ctrl.$onInit() |
| 74 | + ctrl.tags.length = 0 |
| 75 | + ctrl.addTag({code: 1, text: '1'}) |
| 76 | + ctrl.removeTag({code: 1}) |
| 77 | + expect(ctrl.tags.length).toBe(0) |
| 78 | + }) |
79 | 79 |
|
80 | 80 | it('should reset the tag list', () => { |
81 | | - ctrl.$onInit(); |
82 | | - expect(ctrl.path.length).toBe(0); |
83 | | - }); |
| 81 | + ctrl.$onInit() |
| 82 | + expect(ctrl.path.length).toBe(0) |
| 83 | + }) |
84 | 84 |
|
85 | 85 | it('should go to the selected element in the tree', () => { |
86 | | - ctrl.$onInit(); |
87 | | - const pathLength = ctrl.path.length; |
88 | | - ctrl.next('subLevel'); |
89 | | - expect(ctrl.path.length).toBe(pathLength + 1); |
90 | | - }); |
| 86 | + ctrl.$onInit() |
| 87 | + const pathLength = ctrl.path.length |
| 88 | + ctrl.next('subLevel') |
| 89 | + expect(ctrl.path.length).toBe(pathLength + 1) |
| 90 | + }) |
91 | 91 |
|
92 | 92 | it('should back to the previous element in the tree when on the root', () => { |
93 | | - ctrl.$onInit(); |
94 | | - ctrl.path = []; |
95 | | - ctrl.previous(); |
96 | | - expect(ctrl.path.length).toBe(0); |
97 | | - }); |
| 93 | + ctrl.$onInit() |
| 94 | + ctrl.path = [] |
| 95 | + ctrl.previous() |
| 96 | + expect(ctrl.path.length).toBe(0) |
| 97 | + }) |
98 | 98 |
|
99 | 99 | it('should back to the previous element in the tree when in 2 sublevels', () => { |
100 | | - ctrl.$onInit(); |
101 | | - ctrl.next('subLevel'); |
102 | | - ctrl.next('subSubLevel'); |
103 | | - ctrl.previous(); |
104 | | - expect(ctrl.path.length).toBe(1); |
105 | | - }); |
106 | | - }); |
107 | | -}); |
| 100 | + ctrl.$onInit() |
| 101 | + ctrl.next('subLevel') |
| 102 | + ctrl.next('subSubLevel') |
| 103 | + ctrl.previous() |
| 104 | + expect(ctrl.path.length).toBe(1) |
| 105 | + }) |
| 106 | + }) |
| 107 | +}) |
0 commit comments