|
1 | 1 | describe('alert', function () {
|
2 |
| - var scope, $compile; |
| 2 | + var scope, $compile, $templateCache; |
3 | 3 | var element;
|
4 | 4 |
|
5 | 5 | beforeEach(module('ui.bootstrap.alert'));
|
6 | 6 | beforeEach(module('template/alert/alert.html'));
|
7 | 7 |
|
8 |
| - beforeEach(inject(function ($rootScope, _$compile_) { |
| 8 | + beforeEach(inject(function ($rootScope, _$compile_, _$templateCache_) { |
9 | 9 |
|
10 | 10 | scope = $rootScope;
|
11 | 11 | $compile = _$compile_;
|
| 12 | + $templateCache = _$templateCache_; |
12 | 13 |
|
13 | 14 | element = angular.element(
|
14 | 15 | '<div>' +
|
@@ -38,6 +39,30 @@ describe('alert', function () {
|
38 | 39 | return element.find('div[ng-transclude] span').eq(index);
|
39 | 40 | }
|
40 | 41 |
|
| 42 | + it('should expose the controller to the view', function () { |
| 43 | + $templateCache.put('template/alert/alert.html', '<div>{{alert.text}}</div>'); |
| 44 | + |
| 45 | + element = $compile('<alert></alert>')(scope); |
| 46 | + scope.$digest(); |
| 47 | + |
| 48 | + var ctrl = element.controller('alert'); |
| 49 | + expect(ctrl).toBeDefined(); |
| 50 | + |
| 51 | + ctrl.text = 'foo'; |
| 52 | + scope.$digest(); |
| 53 | + |
| 54 | + expect(element.html()).toBe('foo'); |
| 55 | + }); |
| 56 | + |
| 57 | + it('should support custom templates', function () { |
| 58 | + $templateCache.put('foo/bar.html', '<div>baz</div>'); |
| 59 | + |
| 60 | + element = $compile('<alert template-url="foo/bar.html"></alert>')(scope); |
| 61 | + scope.$digest(); |
| 62 | + |
| 63 | + expect(element.html()).toBe('baz'); |
| 64 | + }); |
| 65 | + |
41 | 66 | it('should generate alerts using ng-repeat', function () {
|
42 | 67 | var alerts = createAlerts();
|
43 | 68 | expect(alerts.length).toEqual(3);
|
|
0 commit comments