@@ -4,6 +4,9 @@ describe('tooltip directive', function () {
4
4
5
5
beforeEach ( module ( 'ui.bootstrap.tooltip' ) ) ;
6
6
beforeEach ( module ( 'template/tooltip/tooltip-popup.html' ) ) ;
7
+ beforeEach ( module ( 'template/tooltip/tooltip-template-popup.html' ) ) ;
8
+ beforeEach ( module ( 'template/tooltip/tooltip-html-popup.html' ) ) ;
9
+ beforeEach ( module ( 'template/tooltip/tooltip-html-unsafe-popup.html' ) ) ;
7
10
beforeEach ( inject ( function ( _$rootScope_ , _$compile_ , _$document_ , _$timeout_ ) {
8
11
$rootScope = _$rootScope_ ;
9
12
$compile = _$compile_ ;
@@ -95,34 +98,55 @@ describe('tooltip directive', function () {
95
98
96
99
describe ( 'option by option' , function ( ) {
97
100
98
- describe ( 'placement' , function ( ) {
101
+ var tooltipTypes = {
102
+ 'tooltip' : 'tooltip="tooltip text"' ,
103
+ 'tooltip-html' : 'tooltip-html="tooltipSafeHtml"' ,
104
+ 'tooltip-html-unsafe' : 'tooltip-html-unsafe="tooltip text"' ,
105
+ 'tooltip-template' : 'tooltip-template="\'tooltipTextUrl\'"'
106
+ } ;
99
107
100
- it ( 'can specify an alternative, valid placement' , function ( ) {
101
- var fragment = compileTooltip ( '<span tooltip="tooltip text" tooltip-placement="left">Trigger here</span>' ) ;
102
- fragment . find ( 'span' ) . trigger ( 'mouseenter' ) ;
108
+ beforeEach ( inject ( function ( $sce , $templateCache ) {
109
+ $rootScope . tooltipText = 'tooltip text' ;
110
+ $rootScope . tooltipSafeHtml = $sce . trustAsHtml ( 'tooltip text' ) ;
111
+ $templateCache . put ( 'tooltipTextUrl' , [ 200 , '<span>tooltip text</span>' , { } ] ) ;
112
+ } ) ) ;
103
113
104
- var ttipElement = fragment . find ( 'div.tooltip' ) ;
105
- expect ( fragment ) . toHaveOpenTooltips ( ) ;
106
- expect ( ttipElement ) . toHaveClass ( 'left' ) ;
114
+ angular . forEach ( tooltipTypes , function ( html , key ) {
107
115
108
- closeTooltip ( fragment . find ( 'span' ) ) ;
109
- expect ( fragment ) . not . toHaveOpenTooltips ( ) ;
110
- } ) ;
116
+ describe ( key , function ( ) {
111
117
112
- } ) ;
118
+ describe ( 'placement' , function ( ) {
119
+
120
+ it ( 'can specify an alternative, valid placement' , function ( ) {
121
+ var fragment = compileTooltip ( '<span ' + html + ' tooltip-placement="left">Trigger here</span>' ) ;
122
+ fragment . find ( 'span' ) . trigger ( 'mouseenter' ) ;
123
+
124
+ var ttipElement = fragment . find ( 'div.tooltip' ) ;
125
+ expect ( fragment ) . toHaveOpenTooltips ( ) ;
126
+ expect ( ttipElement ) . toHaveClass ( 'left' ) ;
127
+
128
+ closeTooltip ( fragment . find ( 'span' ) ) ;
129
+ expect ( fragment ) . not . toHaveOpenTooltips ( ) ;
130
+ } ) ;
131
+
132
+ } ) ;
133
+
134
+ describe ( 'class' , function ( ) {
135
+
136
+ it ( 'can specify a custom class' , function ( ) {
137
+ var fragment = compileTooltip ( '<span ' + html + ' tooltip-class="custom">Trigger here</span>' ) ;
138
+ fragment . find ( 'span' ) . trigger ( 'mouseenter' ) ;
113
139
114
- describe ( 'class' , function ( ) {
140
+ var ttipElement = fragment . find ( 'div.tooltip' ) ;
141
+ expect ( fragment ) . toHaveOpenTooltips ( ) ;
142
+ expect ( ttipElement ) . toHaveClass ( 'custom' ) ;
115
143
116
- it ( 'can specify a custom class' , function ( ) {
117
- var fragment = compileTooltip ( '<span tooltip="tooltip text" tooltip-class="custom">Trigger here</span>' ) ;
118
- fragment . find ( 'span' ) . trigger ( 'mouseenter' ) ;
144
+ closeTooltip ( fragment . find ( 'span' ) ) ;
145
+ expect ( fragment ) . not . toHaveOpenTooltips ( ) ;
146
+ } ) ;
119
147
120
- var ttipElement = fragment . find ( 'div.tooltip' ) ;
121
- expect ( fragment ) . toHaveOpenTooltips ( ) ;
122
- expect ( ttipElement ) . toHaveClass ( 'custom' ) ;
148
+ } ) ;
123
149
124
- closeTooltip ( fragment . find ( 'span' ) ) ;
125
- expect ( fragment ) . not . toHaveOpenTooltips ( ) ;
126
150
} ) ;
127
151
128
152
} ) ;
0 commit comments