|
1 | 1 | describe('input-tags', () => { |
2 | | - let element; |
3 | | - let scope; |
| 2 | + let $componentController; |
4 | 3 |
|
5 | | - beforeEach(inject((_$rootScope_, _$compile_) => { |
6 | | - const $compile = _$compile_; |
7 | | - scope = _$rootScope_.$new(); |
8 | | - |
9 | | - element = angular.element('<div>test</div>'); |
10 | | - |
11 | | - $compile(element)(scope); |
| 4 | + beforeEach(angular.mock.module('angularjs-input-tags')); |
| 5 | + beforeEach(angular.mock.inject(_$componentController_ => { |
| 6 | + $componentController = _$componentController_; |
12 | 7 | })); |
13 | 8 |
|
14 | | - it('should dummy test pass', () => { |
15 | | - const expected = 'test'; |
16 | | - scope.item = { |
17 | | - name: expected, |
18 | | - active: false |
19 | | - }; |
20 | | - |
21 | | - scope.$digest(); |
| 9 | + describe('addTag', () => { |
| 10 | + it('should emit `onTagAdding` callback', () => { |
| 11 | + const onTagAddingSpy = jasmine.createSpy('onTagAdding'); |
| 12 | + const bindings = {onTagAdding: onTagAddingSpy}; |
| 13 | + const ctrl = $componentController('inputTags', undefined, bindings); |
| 14 | + ctrl.$onInit(); |
| 15 | + ctrl.addTag({code: 1, text: '1'}); |
| 16 | + expect(onTagAddingSpy).toHaveBeenCalledWith({code: 1, text: '1'}); |
| 17 | + }); |
22 | 18 |
|
23 | | - expect(element.text()).toContain(expected); |
| 19 | + it('should update tag list', () => { |
| 20 | + const ctrl = $componentController('inputTags'); |
| 21 | + ctrl.$onInit(); |
| 22 | + ctrl.addTag({code: 1, text: '1'}); |
| 23 | + expect(ctrl.tags).toContain({code: 1, text: '1'}); |
| 24 | + }); |
24 | 25 | }); |
25 | 26 | }); |
0 commit comments