|
1 | 1 | describe('timepicker directive', function() {
|
2 |
| - var $rootScope, $compile, element; |
| 2 | + var $rootScope, $compile, $templateCache, element; |
3 | 3 |
|
4 | 4 | beforeEach(module('ui.bootstrap.timepicker'));
|
5 | 5 | beforeEach(module('template/timepicker/timepicker.html'));
|
6 |
| - beforeEach(inject(function(_$compile_, _$rootScope_) { |
| 6 | + beforeEach(inject(function(_$compile_, _$rootScope_, _$templateCache_) { |
7 | 7 | $compile = _$compile_;
|
8 | 8 | $rootScope = _$rootScope_;
|
9 | 9 | $rootScope.time = newTime(14, 40);
|
| 10 | + $templateCache = _$templateCache_; |
10 | 11 |
|
11 | 12 | element = $compile('<timepicker ng-model="time"></timepicker>')($rootScope);
|
12 | 13 | $rootScope.$digest();
|
@@ -1692,4 +1693,30 @@ describe('timepicker directive', function() {
|
1692 | 1693 | expect(element.hasClass('ng-invalid-time')).toBe(false);
|
1693 | 1694 | });
|
1694 | 1695 | });
|
| 1696 | + |
| 1697 | + describe('custom template and controllerAs', function() { |
| 1698 | + it('should allow custom templates', function() { |
| 1699 | + $templateCache.put('foo/bar.html', '<div>baz</div>'); |
| 1700 | + |
| 1701 | + element = $compile('<timepicker ng-model="time" template-url="foo/bar.html"></timepicker>')($rootScope); |
| 1702 | + $rootScope.$digest(); |
| 1703 | + expect(element[0].tagName.toLowerCase()).toBe('div'); |
| 1704 | + expect(element.html()).toBe('baz'); |
| 1705 | + }); |
| 1706 | + |
| 1707 | + it('should expose the controller on the view', function() { |
| 1708 | + $templateCache.put('template/timepicker/timepicker.html', '<div><div>{{timepicker.text}}</div></div>'); |
| 1709 | + |
| 1710 | + element = $compile('<timepicker ng-model="time"></timepicker>')($rootScope); |
| 1711 | + $rootScope.$digest(); |
| 1712 | + |
| 1713 | + var ctrl = element.controller('timepicker'); |
| 1714 | + expect(ctrl).toBeDefined(); |
| 1715 | + |
| 1716 | + ctrl.text = 'foo'; |
| 1717 | + $rootScope.$digest(); |
| 1718 | + |
| 1719 | + expect(element.html()).toBe('<div class="ng-binding">foo</div>'); |
| 1720 | + }); |
| 1721 | + }); |
1695 | 1722 | });
|
0 commit comments