Skip to content

Commit 6a515ec

Browse files
committed
Define pertinent tests
1 parent 6ddb21e commit 6a515ec

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/input-tags.spec.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
describe('input-tags', () => {
2-
let element;
3-
let scope;
2+
let $componentController;
43

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_;
127
}));
138

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+
});
2218

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+
});
2425
});
2526
});

0 commit comments

Comments
 (0)